talent-plan / tinysql

A course to build the SQL layer of a distributed database.
Apache License 2.0
1.7k stars 519 forks source link

parser, tests: `TestscanString` type conversion failed #75

Closed hidehalo closed 3 years ago

hidehalo commented 3 years ago

Description

If you are working on project 2(implement&test JoinTable for SQL parser), you maybe would get an error as below:

./lexer_test.go:199:12: conversion from untyped int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)

that code block looked like:

191   func (s *testLexerSuite) TestscanString(c *C) {
192    table := []struct {
193        raw    string
194        expect string
195    }{
196        {`' \n\tTest String'`, " \n\tTest String"},
197        {`'\x\B'`, "xB"},
198        {`'\0\'\"\b\n\r\t\\'`, "\000'\"\b\n\r\t\\"},
199        {`'\Z'`, string(26)},// Error

It broke tests but not a user cause

Advice

use hardcoded string