Exemple #1
0
func stringToLines(data string) []line.Line {
	result := []line.Line{}
	reader := bufio.NewReader(strings.NewReader(data))
	for {
		currentLine, _, err := reader.ReadLine()
		if err != nil {
			break
		}
		current := line.NewLine()
		if current.Parse(string(currentLine)) {
			result = append(result, *current)
		}
	}
	return result
}
Exemple #2
0
func TestLineParse(t *testing.T) {
	testCaseList := []testCaseForTestLineParse{
		{data: `EX11     START`},
		{data: `         LD      GR0, DATA1`},
		{data: `         RET`},
		{data: `DATA1    DC      #1234`},
		{data: `         END`},
	}
	for testIndex, testCase := range testCaseList {
		testData := testCase.data
		target := line.NewLine()
		ok := target.Parse(testData)
		if !ok {
			t.Errorf("testCase[%d]=%#v\n", testIndex, testData)
		}
		t.Errorf("%#v\n", target)
	}
}