This repository has been archived on 2025-09-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2025LogProg-project-GhentPr.../tests/lexer/LexerScanTest.kt

35 lines
953 B
Kotlin

package be.ugent.logprog.lexer
import lexer.Error
import lexer.Lexer
import lexer.TokenType
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import kotlin.test.assertEquals
class LexerScanTest {
@Test
fun scan_emptyString_returnsEOF() {
val lexer = Lexer("")
val tokens = lexer.scan()
assertEquals(1, tokens.size)
assertEquals(TokenType.EOF, tokens[0].type)
}
@Test
fun scan_unknownSymbol_returnsError() {
val lexer = Lexer("")
assertThrows<Error>({
val tokens = lexer.scan()
})
}
@Test
fun scan_dot_returnsDot() {
val lexer = Lexer(".")
val tokens = lexer.scan()
assertEquals(2, tokens.size)
assertEquals(TokenType.DOT, tokens[0].type, "Expected DOT token, got ${tokens[0].type}")
assertEquals(TokenType.EOF, tokens[1].type, "Expected EOF token, got ${tokens[1].type}")
}
}