require File.dirname(__FILE__) + '/test_helper.rb' class ADLScannerTest < Test::Unit::TestCase def setup @scanner = OpenEHR::ADL::Scanner::ADLScanner.new([:adl], "filename") end must "assert OpenEHR::ADL::Scanner::ADLScanner scanner instance" do assert_instance_of OpenEHR::ADL::Scanner::ADLScanner, @scanner end must "assert ADLScanner scanner scan CR and lineno incremented" do lineno = @scanner.lineno @scanner.scan("\n") assert_equal lineno+1, @scanner.lineno end must "assert ADLScanner scanner scan ARCHETYPE_ID" do lineno = @scanner.lineno @scanner.scan("openEHR-EHR-OBSERVATION.body_mass_index.v1") do |sym, val| assert_equal :V_ARCHETYPE_ID,sym assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID,val end end must "assert ADLScanner scanner scan white space and lineno unchanged" do lineno = @scanner.lineno @scanner.scan(" ") assert_equal lineno, @scanner.lineno end must "assert ADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val| assert_equal :V_QUALIFIED_TERM_CODE_REF,sym assert_equal "ICD10AM(1998)::F23",val end end end class CADLScannerTest < Test::Unit::TestCase def setup @scanner = OpenEHR::ADL::Scanner::CADLScanner.new([:cadl], "filename") end must "assert OpenEHR::ADL::Scanner::CADLScanner scanner instance" do assert_instance_of OpenEHR::ADL::Scanner::CADLScanner, @scanner end must "assert CADLScanner scanner scan V_ATTRIBUTE_IDENTIFIER" do lineno = @scanner.lineno @scanner.scan("identifier") do |sym, val| assert_equal :V_ATTRIBUTE_IDENTIFIER, sym assert_equal "identifier", val end assert_equal lineno, @scanner.lineno end must "assert CADLScanner scanner scan reserved words" do lineno = @scanner.lineno @scanner.scan("then") do |sym, val| assert_equal :SYM_THEN, sym end end must "assert CADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val| assert_equal :V_QUALIFIED_TERM_CODE_REF,sym assert_equal "ICD10AM(1998)::F23",val end end must "assert CADLScanner scanner scan V_ISO8601_DURATION" do @scanner.scan("PT1M") do |sym, val| assert_equal :V_ISO8601_DURATION,sym assert_equal "PT1M",val end end end class DADLScannerTest < Test::Unit::TestCase def setup @scanner = OpenEHR::ADL::Scanner::DADLScanner.new([:dadl], "filename") end must "assert DADLScanner scanner scan V_QUALIFIED_TERM_CODE_REF" do @scanner.scan("[ICD10AM(1998)::F23]") do |sym, val| assert_equal :V_QUALIFIED_TERM_CODE_REF,sym assert_equal "ICD10AM(1998)::F23",val end end must "assert DADLScanner scanner scan V_ISO8601_EXTENDED_DATE" do @scanner.scan("2005-10-10") do |sym, val| assert_equal :V_ISO8601_EXTENDED_DATE,sym assert_equal "2005-10-10",val end end must "assert DADLScanner scanner scan V_STRING" do @scanner.scan("\"string\"") do |sym, val| assert_equal :V_STRING,sym assert_equal "string",val end end end