package mmql import ( // "fmt" "testing" ) func TestParse( t *testing.T ) { lexer := Lexer{} s, err := lexer.Parse( "\"ABC\"" ) if err != nil { t.Error( err ) } got := (*any( s ).( QuotedValue ).RawStatement).Value if got != "ABC" { t.Errorf( "Expected ABC, got %s", got ) } s, err = lexer.Parse( "\"ABC" ) if err == nil { t.Errorf( "Expected error, got value %s", s ) } s, err = lexer.Parse( "( ABC )" ) got = (*any( s ).( BracketedValue ).RawStatement).Value if got != " ABC " { t.Errorf( "Expected ABC, got %s", got ) } s, err = lexer.Parse( "( ABC" ) if err == nil { t.Errorf( "Expected error, got value %s", s ) } s, err = lexer.Parse( ` BUY 1 SHARES OF BTC_ETF FOR 10 USD FROM "MyBrokerAccount" WITH LIMIT OF PURCHASING_POWER( "MyBrokerAccount", "QQQ" ) FOR EVERY 1 BTC OF USD_BTC SOLD FROM "CoinBase" ` ) if err != nil { t.Error( err ) } }