This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class codeGolf.Pyramid | |
{ | |
ClassMethod Build(f As %Integer) | |
{ | |
; Your code here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class codeGolf.test.Pyramid Extends %UnitTest.TestCase | |
{ | |
ClassMethod openDisplay(Output filename As %String) | |
{ | |
Set dir=##class(%SYSTEM.Process).CurrentDirectory() | |
Set filename=dir_"temp.txt" | |
Open filename:("NRW"):5 | |
USE filename | |
} | |
ClassMethod getResult(filename As %String, Output list As %ListOfDataTypes) | |
{ | |
Set list = ##class(%ListOfDataTypes).%New() | |
Set file = ##class(%File).%New(filename) | |
Set sc = file.Open( "R" ) | |
If $$$ISERR(sc) quit | |
While 'file.AtEnd { | |
Do list.Insert(file.ReadLine()) | |
} | |
Do file.Close() | |
Do ##class(%File).Delete(filename) | |
} | |
Method TestSimple() | |
{ | |
Do ..openDisplay(.filename) | |
Do ##class(codeGolf.Pyramid).Build(3) | |
CLOSE filename | |
Do ..getResult(filename, .result) | |
Do $$$AssertEquals(result.GetAt(1), " # ") | |
Do $$$AssertEquals(result.GetAt(3), "#####") | |
} | |
Method TestComplex() | |
{ | |
Do ..openDisplay(.filename) | |
Do ##class(codeGolf.Pyramid).Build(40) | |
CLOSE filename | |
Do ..getResult(filename, .result) | |
Do $$$AssertEquals(result.GetAt(1), " # ") | |
Do $$$AssertEquals(result.GetAt(23), " ############################################# ") | |
Do $$$AssertEquals(result.GetAt(40), "###############################################################################") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment