Add decoder tests
This commit is contained in:
parent
24fab8515d
commit
12e11399af
@ -1,3 +1,6 @@
|
|||||||
|
import testparser;
|
||||||
|
import std.stdio;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -5,5 +8,43 @@ int main()
|
|||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
assert(true);
|
alias DCP = Testparser.Decoder.DecodedCodePoint;
|
||||||
|
string inputstring = "5+\n 66";
|
||||||
|
const(ubyte) * input = cast(const(ubyte) *)inputstring.ptr;
|
||||||
|
size_t input_length = inputstring.length;
|
||||||
|
DCP dcp;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP('5', 1u));
|
||||||
|
input += dcp.code_point_length;
|
||||||
|
input_length -= dcp.code_point_length;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP('+', 1u));
|
||||||
|
input += dcp.code_point_length;
|
||||||
|
input_length -= dcp.code_point_length;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP('\n', 1u));
|
||||||
|
input += dcp.code_point_length;
|
||||||
|
input_length -= dcp.code_point_length;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP(' ', 1u));
|
||||||
|
input += dcp.code_point_length;
|
||||||
|
input_length -= dcp.code_point_length;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP('6', 1u));
|
||||||
|
input += dcp.code_point_length;
|
||||||
|
input_length -= dcp.code_point_length;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP('6', 1u));
|
||||||
|
input += dcp.code_point_length;
|
||||||
|
input_length -= dcp.code_point_length;
|
||||||
|
dcp = Testparser.Decoder.decode_code_point(input, input_length);
|
||||||
|
assert(dcp == DCP(Testparser.Decoder.CODE_POINT_EOF, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
alias LT = Testparser.Lexer.LexedToken;
|
||||||
|
string input = "5 + 4 * \n677 + 567";
|
||||||
|
Testparser.Lexer lexer = new Testparser.Lexer(cast(const(ubyte) *)input.ptr, input.sizeof);
|
||||||
|
//assert(lexer.lex_token() == LT(0, 0, Testparser.TOKEN_INT));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user