Also made a litle change to scanner function moveOn(): now it moves on the last char passed and only if there are more than one chars.
		
			
				
	
	
		
			29 lines
		
	
	
		
			834 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			834 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
 | |
| // All rights reserved.
 | |
| 
 | |
| // t_strings_test.go
 | |
| package expr
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func TestStringsParser(t *testing.T) {
 | |
| 	section := "String"
 | |
| 	inputs := []inputType{
 | |
| 		/*  1 */ {`"uno" + "due"`, `unodue`, nil},
 | |
| 		/*  2 */ {`"uno" + 2`, `uno2`, nil},
 | |
| 		/*  3 */ {`"uno" + (2+1)`, `uno3`, nil},
 | |
| 		/*  4 */ {`"uno" * (2+1)`, `unounouno`, nil},
 | |
| 		/*  5 */ {`"abc"[1]`, `b`, nil},
 | |
| 		/*  6 */ {`#"abc"`, int64(3), nil},
 | |
| 		/*  7 */ {`"192.168.0.240" / "."`, newListA("192", "168", "0", "240"), nil},
 | |
| 		/*  8 */ {`("192.168.0.240" / ".")[1]`, "168", nil},
 | |
| 		/*  9 */ {`"AF3B0Dz" / 2`, newListA("AF", "3B", "0D", "z"), nil},
 | |
| 		/* 10 */ {`"AF3B0Dz" / 0`, nil, "[1:12] division by zero"},
 | |
| 	}
 | |
| 
 | |
| 	// runTestSuiteSpec(t, section, inputs, 8)
 | |
| 	runTestSuite(t, section, inputs)
 | |
| }
 |