public void TestJumpTableOptimizationBranches() { for (char i = '\0'; i <= 128; i++) { if (SimpleTokenizer.AllowedSingleCharacters.AsSpan().Contains(i)) { continue; } Assert.Throws <InvalidTokenParsingException>(() => SimpleTokenizer.ParseCharacterToken(i, null)); } }
public void VerifyAllSingleCharTokensParseCorrectly() { var tokenizer = new Compiler.Tokenizer.SimpleTokenizer(); var singleCharTokenClasses = typeof(ISingleCharToken).Assembly.GetTypes().Where(x => !x.IsInterface).Where(x => x.GetInterfaces().Contains(typeof(ISingleCharToken))); foreach (var tokenClass in singleCharTokenClasses) { var tokenCharValueField = tokenClass.GetField("CharValue", BindingFlags.Public | BindingFlags.Static); char c = (char)tokenCharValueField.GetValue(null); Assert.IsType(tokenClass, SimpleTokenizer.ParseCharacterToken(c, null)); } }
public void TestTokenizerInvalidSingleCharTokenFails() { var tokenizer = new Compiler.Tokenizer.SimpleTokenizer(); Assert.Throws <InvalidTokenParsingException>(() => SimpleTokenizer.ParseCharacterToken('c', null)); }