(module tests mzscheme
(require (planet "test.ss" ("schematics" "schemeunit.plt" 1)))
(require (planet "graphical-ui.ss" ("schematics" "schemeunit.plt" 1)))
(require "../../nationality.ss")
(define philippines-tests
(make-test-suite
"Philippines tests"
(make-test-case "singular adjective"
(assert-equal? (nationality-adjective "Philippines, The" 'singular)
"Philippine"))
(make-test-case "feminine singular adjective"
(assert-equal? (nationality-adjective "Philippines, The" 'feminine/singular)
"Philippine"))
(make-test-case "plural adjective"
(assert-equal? (nationality-adjective "Philippines, The" 'plural)
"Philippine"))
(make-test-case "singular noun"
(assert-equal? (nationality-noun "Philippines, The" 'singular)
"Filipino"))
(make-test-case "feminine singular noun"
(assert-equal? (nationality-noun "Philippines, The" 'feminine/singular)
"Filipina"))
(make-test-case "plural noun"
(assert-equal? (nationality-noun "Philippines, The" 'plural)
"Filipinos"))
))
(define two-part-country-tests
(make-test-suite
"two-part country tests"
))
(define (has-adjective-forall-types? location)
(and (nationality-adjective location 'singular)
(nationality-adjective location 'feminine/singular)
(nationality-adjective location 'plural)
#t))
(define general-tests
(make-test-suite
"general tests"
(make-test-case "every inhabited country has an adjective for all adjective types"
(assert-true (andmap has-adjective-forall-types? inhabited-locations)))
(make-test-case "uninhabited location is a location"
(assert-true (location? "Antarctica")))
(make-test-case "uninhabited location is uninhabited"
(assert-false (location-inhabited? "Antarctica")))
(make-test-case "inhabited location is a location"
(assert-true (location? "France")))
(make-test-case "inhabited location is not uninhabited"
(assert-true (location-inhabited? "France")))
(make-test-case "non-location cannot be tested for being inhabited"
(assert-exn exn? (lambda ()
(location-inhabited? "Boobooland"))))
))
(define location->phrase-tests
(make-test-suite "location->phrase tests"
(make-test-case "US default"
(assert-equal? "The United States" (location->phrase "United States, The")))
(make-test-case "US capitalized"
(assert-equal? "The United States" (location->phrase "United States, The" #t)))
(make-test-case "US uncapitalized"
(assert-equal? "the United States" (location->phrase "United States, The" #f)))
(make-test-case "Belgium default"
(assert-equal? "Belgium" (location->phrase "Belgium")))
(make-test-case "Belgium capitalized"
(assert-equal? "Belgium" (location->phrase "Belgium" #t)))
(make-test-case "Belgium uncapitalized"
(assert-equal? "Belgium" (location->phrase "Belgium" #f)))
(make-test-case "DR of Congo default"
(assert-equal? "The Democratic Republic of the Congo" (location->phrase "Congo, The Democratic Republic of the")))
(make-test-case "DR of Congo capitalized"
(assert-equal? "The Democratic Republic of the Congo" (location->phrase "Congo, The Democratic Republic of the" #t)))
(make-test-case "DR of Congo uncapitalized"
(assert-equal? "the Democratic Republic of the Congo" (location->phrase "Congo, The Democratic Republic of the" #f)))))
(define all-tests
(make-test-suite
"all nationality.plt tests"
philippines-tests
two-part-country-tests
general-tests
location->phrase-tests
))
(test/graphical-ui all-tests)
(provide all-tests))