trackler 2.2.1.110 → 2.2.1.111
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/house/canonical-data.json +28 -200
- data/problem-specifications/exercises/react/canonical-data.json +49 -2
- data/tracks/c/config.json +49 -0
- data/tracks/c/exercises/crypto-square/README.md +69 -0
- data/tracks/c/exercises/crypto-square/makefile +25 -0
- data/tracks/c/exercises/crypto-square/src/example.c +87 -0
- data/tracks/c/exercises/crypto-square/src/example.h +6 -0
- data/tracks/c/exercises/crypto-square/test/test_crypto_square.c +99 -0
- data/tracks/c/exercises/crypto-square/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/crypto-square/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/crypto-square/test/vendor/unity_internals.h +701 -0
- data/tracks/c/exercises/pig-latin/README.md +17 -0
- data/tracks/c/exercises/pig-latin/makefile +25 -0
- data/tracks/c/exercises/pig-latin/src/example.c +128 -0
- data/tracks/c/exercises/pig-latin/src/example.h +6 -0
- data/tracks/c/exercises/pig-latin/test/test_pig_latin.c +239 -0
- data/tracks/c/exercises/pig-latin/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/pig-latin/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/pig-latin/test/vendor/unity_internals.h +701 -0
- data/tracks/c/exercises/say/README.md +62 -0
- data/tracks/c/exercises/say/makefile +27 -0
- data/tracks/c/exercises/say/src/example.c +144 -0
- data/tracks/c/exercises/say/src/example.h +7 -0
- data/tracks/c/exercises/say/test/test_say.c +185 -0
- data/tracks/c/exercises/say/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/say/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/say/test/vendor/unity_internals.h +701 -0
- data/tracks/c/exercises/secret-handshake/README.md +28 -0
- data/tracks/c/exercises/secret-handshake/makefile +25 -0
- data/tracks/c/exercises/secret-handshake/src/example.c +60 -0
- data/tracks/c/exercises/secret-handshake/src/example.h +7 -0
- data/tracks/c/exercises/secret-handshake/test/test_secret_handshake.c +133 -0
- data/tracks/c/exercises/secret-handshake/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/secret-handshake/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/secret-handshake/test/vendor/unity_internals.h +701 -0
- data/tracks/coffeescript/config/exercise_readme.go.tmpl +7 -4
- data/tracks/coffeescript/exercises/accumulate/README.md +0 -3
- data/tracks/coffeescript/exercises/atbash-cipher/README.md +2 -1
- data/tracks/coffeescript/exercises/beer-song/README.md +2 -2
- data/tracks/coffeescript/exercises/binary/README.md +2 -0
- data/tracks/coffeescript/exercises/linked-list/README.md +10 -10
- data/tracks/coffeescript/exercises/luhn/README.md +7 -7
- data/tracks/coffeescript/exercises/nucleotide-count/README.md +8 -22
- data/tracks/coffeescript/exercises/palindrome-products/README.md +15 -16
- data/tracks/coffeescript/exercises/pascals-triangle/README.md +2 -2
- data/tracks/coffeescript/exercises/queen-attack/README.md +1 -1
- data/tracks/coffeescript/exercises/triangle/README.md +9 -6
- data/tracks/coffeescript/exercises/trinary/README.md +1 -1
- data/tracks/coffeescript/exercises/word-count/README.md +1 -2
- data/tracks/coffeescript/exercises/wordy/README.md +0 -5
- data/tracks/coq/config/exercise_readme.go.tmpl +23 -4
- data/tracks/coq/exercises/rna-transcription/README.md +2 -2
- data/tracks/cpp/config/exercise_readme.go.tmpl +31 -4
- data/tracks/cpp/exercises/allergies/README.md +0 -1
- data/tracks/cpp/exercises/atbash-cipher/README.md +2 -1
- data/tracks/cpp/exercises/beer-song/README.md +2 -2
- data/tracks/cpp/exercises/binary/README.md +2 -0
- data/tracks/cpp/exercises/crypto-square/README.md +10 -8
- data/tracks/cpp/exercises/etl/README.md +3 -1
- data/tracks/cpp/exercises/food-chain/README.md +1 -1
- data/tracks/cpp/exercises/grade-school/README.md +0 -1
- data/tracks/cpp/exercises/grains/README.md +0 -1
- data/tracks/cpp/exercises/leap/README.md +1 -1
- data/tracks/cpp/exercises/meetup/README.md +16 -13
- data/tracks/cpp/exercises/nucleotide-count/README.md +2 -4
- data/tracks/cpp/exercises/pangram/README.md +1 -1
- data/tracks/cpp/exercises/phone-number/README.md +4 -3
- data/tracks/cpp/exercises/queen-attack/README.md +1 -1
- data/tracks/cpp/exercises/rna-transcription/README.md +2 -2
- data/tracks/cpp/exercises/roman-numerals/README.md +1 -1
- data/tracks/cpp/exercises/scrabble-score/README.md +3 -1
- data/tracks/cpp/exercises/space-age/README.md +1 -2
- data/tracks/cpp/exercises/sum-of-multiples/README.md +3 -6
- data/tracks/cpp/exercises/triangle/README.md +9 -6
- data/tracks/cpp/exercises/trinary/README.md +1 -1
- data/tracks/cpp/exercises/word-count/README.md +1 -2
- data/tracks/d/config/exercise_readme.go.tmpl +30 -4
- data/tracks/d/exercises/circular-buffer/README.md +13 -6
- data/tracks/d/exercises/crypto-square/README.md +10 -8
- data/tracks/d/exercises/etl/README.md +3 -1
- data/tracks/d/exercises/leap/README.md +1 -1
- data/tracks/d/exercises/nucleotide-count/README.md +8 -22
- data/tracks/d/exercises/pangram/README.md +1 -1
- data/tracks/d/exercises/react/README.md +0 -1
- data/tracks/d/exercises/rna-transcription/README.md +2 -2
- data/tracks/d/exercises/roman-numerals/README.md +1 -1
- data/tracks/d/exercises/triangle/README.md +9 -6
- data/tracks/ecmascript/config/exercise_readme.go.tmpl +29 -4
- data/tracks/ecmascript/exercises/accumulate/README.md +1 -4
- data/tracks/ecmascript/exercises/acronym/README.md +1 -2
- data/tracks/ecmascript/exercises/all-your-base/README.md +2 -3
- data/tracks/ecmascript/exercises/allergies/README.md +1 -2
- data/tracks/ecmascript/exercises/alphametics/README.md +3 -4
- data/tracks/ecmascript/exercises/anagram/README.md +1 -1
- data/tracks/ecmascript/exercises/atbash-cipher/README.md +3 -2
- data/tracks/ecmascript/exercises/beer-song/README.md +3 -3
- data/tracks/ecmascript/exercises/binary-search-tree/README.md +1 -1
- data/tracks/ecmascript/exercises/binary-search/README.md +1 -1
- data/tracks/ecmascript/exercises/binary/README.md +3 -1
- data/tracks/ecmascript/exercises/bowling/README.md +32 -15
- data/tracks/ecmascript/exercises/bracket-push/README.md +1 -1
- data/tracks/ecmascript/exercises/change/README.md +19 -10
- data/tracks/ecmascript/exercises/circular-buffer/README.md +14 -7
- data/tracks/ecmascript/exercises/clock/README.md +1 -1
- data/tracks/ecmascript/exercises/collatz-conjecture/README.md +5 -1
- data/tracks/ecmascript/exercises/complex-numbers/README.md +2 -2
- data/tracks/ecmascript/exercises/connect/README.md +2 -3
- data/tracks/ecmascript/exercises/crypto-square/README.md +11 -9
- data/tracks/ecmascript/exercises/custom-set/README.md +1 -2
- data/tracks/ecmascript/exercises/diamond/README.md +7 -7
- data/tracks/ecmascript/exercises/difference-of-squares/README.md +1 -1
- data/tracks/ecmascript/exercises/diffie-hellman/README.md +1 -1
- data/tracks/ecmascript/exercises/etl/README.md +4 -2
- data/tracks/ecmascript/exercises/flatten-array/README.md +2 -3
- data/tracks/ecmascript/exercises/food-chain/README.md +2 -2
- data/tracks/ecmascript/exercises/gigasecond/README.md +1 -1
- data/tracks/ecmascript/exercises/grade-school/README.md +1 -2
- data/tracks/ecmascript/exercises/grains/README.md +1 -2
- data/tracks/ecmascript/exercises/hamming/README.md +1 -1
- data/tracks/ecmascript/exercises/hello-world/README.md +1 -1
- data/tracks/ecmascript/exercises/hexadecimal/README.md +1 -1
- data/tracks/ecmascript/exercises/house/README.md +1 -5
- data/tracks/ecmascript/exercises/isbn-verifier/README.md +32 -17
- data/tracks/ecmascript/exercises/isogram/README.md +3 -2
- data/tracks/ecmascript/exercises/kindergarten-garden/README.md +14 -14
- data/tracks/ecmascript/exercises/largest-series-product/README.md +1 -1
- data/tracks/ecmascript/exercises/leap/README.md +2 -2
- data/tracks/ecmascript/exercises/linked-list/README.md +11 -11
- data/tracks/ecmascript/exercises/list-ops/README.md +1 -2
- data/tracks/ecmascript/exercises/luhn/README.md +8 -8
- data/tracks/ecmascript/exercises/matrix/README.md +7 -5
- data/tracks/ecmascript/exercises/meetup/README.md +17 -14
- data/tracks/ecmascript/exercises/minesweeper/README.md +1 -2
- data/tracks/ecmascript/exercises/nth-prime/README.md +1 -1
- data/tracks/ecmascript/exercises/ocr-numbers/README.md +7 -7
- data/tracks/ecmascript/exercises/octal/README.md +7 -3
- data/tracks/ecmascript/exercises/palindrome-products/README.md +16 -17
- data/tracks/ecmascript/exercises/pangram/README.md +2 -2
- data/tracks/ecmascript/exercises/pascals-triangle/README.md +3 -3
- data/tracks/ecmascript/exercises/perfect-numbers/README.md +3 -3
- data/tracks/ecmascript/exercises/phone-number/README.md +5 -4
- data/tracks/ecmascript/exercises/pig-latin/README.md +1 -1
- data/tracks/ecmascript/exercises/prime-factors/README.md +1 -1
- data/tracks/ecmascript/exercises/protein-translation/README.md +8 -8
- data/tracks/ecmascript/exercises/proverb/README.md +17 -27
- data/tracks/ecmascript/exercises/pythagorean-triplet/README.md +4 -4
- data/tracks/ecmascript/exercises/queen-attack/README.md +2 -2
- data/tracks/ecmascript/exercises/raindrops/README.md +1 -1
- data/tracks/ecmascript/exercises/react/README.md +8 -1
- data/tracks/ecmascript/exercises/rectangles/README.md +11 -10
- data/tracks/ecmascript/exercises/rna-transcription/README.md +3 -3
- data/tracks/ecmascript/exercises/robot-name/README.md +1 -1
- data/tracks/ecmascript/exercises/robot-simulator/README.md +1 -1
- data/tracks/ecmascript/exercises/roman-numerals/README.md +2 -2
- data/tracks/ecmascript/exercises/rotational-cipher/README.md +3 -2
- data/tracks/ecmascript/exercises/run-length-encoding/README.md +9 -8
- data/tracks/ecmascript/exercises/saddle-points/README.md +3 -3
- data/tracks/ecmascript/exercises/say/README.md +1 -1
- data/tracks/ecmascript/exercises/scrabble-score/README.md +4 -2
- data/tracks/ecmascript/exercises/secret-handshake/README.md +3 -3
- data/tracks/ecmascript/exercises/series/README.md +1 -1
- data/tracks/ecmascript/exercises/sieve/README.md +1 -1
- data/tracks/ecmascript/exercises/simple-cipher/README.md +6 -8
- data/tracks/ecmascript/exercises/simple-linked-list/README.md +2 -1
- data/tracks/ecmascript/exercises/space-age/README.md +2 -2
- data/tracks/ecmascript/exercises/spiral-matrix/README.md +4 -3
- data/tracks/ecmascript/exercises/strain/README.md +1 -1
- data/tracks/ecmascript/exercises/sublist/README.md +1 -1
- data/tracks/ecmascript/exercises/sum-of-multiples/README.md +4 -7
- data/tracks/ecmascript/exercises/transpose/README.md +3 -2
- data/tracks/ecmascript/exercises/triangle/README.md +10 -7
- data/tracks/ecmascript/exercises/trinary/README.md +2 -2
- data/tracks/ecmascript/exercises/twelve-days/README.md +3 -4
- data/tracks/ecmascript/exercises/two-bucket/README.md +11 -11
- data/tracks/ecmascript/exercises/two-fer/README.md +8 -6
- data/tracks/ecmascript/exercises/word-count/README.md +2 -3
- data/tracks/ecmascript/exercises/word-search/README.md +2 -1
- data/tracks/ecmascript/exercises/wordy/README.md +1 -6
- data/tracks/elixir/exercises/bob/bob_test.exs +1 -1
- data/tracks/elixir/exercises/bob/example.exs +13 -9
- data/tracks/elm/config.json +28 -0
- data/tracks/elm/config/exercise_readme.go.tmpl +3 -3
- data/tracks/elm/docs/INSTALLATION.md +6 -2
- data/tracks/elm/exercises/accumulate/README.md +3 -3
- data/tracks/elm/exercises/acronym/Acronym.elm +1 -0
- data/tracks/elm/exercises/acronym/Acronym.example.elm +22 -0
- data/tracks/elm/exercises/acronym/README.md +44 -0
- data/tracks/elm/exercises/acronym/elm-package.json +15 -0
- data/tracks/elm/exercises/acronym/tests/Tests.elm +35 -0
- data/tracks/elm/exercises/acronym/tests/elm-package.json +16 -0
- data/tracks/elm/exercises/all-your-base/README.md +3 -3
- data/tracks/elm/exercises/allergies/README.md +3 -3
- data/tracks/elm/exercises/anagram/README.md +3 -3
- data/tracks/elm/exercises/atbash-cipher/README.md +3 -3
- data/tracks/elm/exercises/binary-search/README.md +3 -3
- data/tracks/elm/exercises/bob/README.md +3 -5
- data/tracks/elm/exercises/collatz-conjecture/README.md +3 -3
- data/tracks/elm/exercises/difference-of-squares/README.md +3 -3
- data/tracks/elm/exercises/etl/README.md +3 -3
- data/tracks/elm/exercises/gigasecond/README.md +3 -3
- data/tracks/elm/exercises/grade-school/README.md +3 -3
- data/tracks/elm/exercises/grains/README.md +3 -3
- data/tracks/elm/exercises/hamming/README.md +3 -3
- data/tracks/elm/exercises/hello-world/README.md +3 -3
- data/tracks/elm/exercises/isogram/README.md +3 -3
- data/tracks/elm/exercises/largest-series-product/README.md +3 -3
- data/tracks/elm/exercises/leap/README.md +3 -3
- data/tracks/elm/exercises/list-ops/README.md +3 -3
- data/tracks/elm/exercises/luhn/Luhn.elm +1 -0
- data/tracks/elm/exercises/luhn/Luhn.example.elm +51 -0
- data/tracks/elm/exercises/luhn/README.md +101 -0
- data/tracks/elm/exercises/luhn/elm-package.json +15 -0
- data/tracks/elm/exercises/luhn/tests/Tests.elm +62 -0
- data/tracks/elm/exercises/luhn/tests/elm-package.json +16 -0
- data/tracks/elm/exercises/nucleotide-count/README.md +3 -3
- data/tracks/elm/exercises/pangram/.meta/description.md +7 -0
- data/tracks/elm/exercises/pangram/README.md +4 -4
- data/tracks/elm/exercises/pascals-triangle/README.md +3 -3
- data/tracks/elm/exercises/phone-number/README.md +3 -3
- data/tracks/elm/exercises/raindrops/README.md +3 -3
- data/tracks/elm/exercises/rna-transcription/README.md +4 -4
- data/tracks/elm/exercises/robot-simulator/README.md +3 -3
- data/tracks/elm/exercises/roman-numerals/README.md +3 -3
- data/tracks/elm/exercises/run-length-encoding/README.md +3 -3
- data/tracks/elm/exercises/say/README.md +3 -3
- data/tracks/elm/exercises/scrabble-score/README.md +3 -3
- data/tracks/elm/exercises/series/README.md +3 -3
- data/tracks/elm/exercises/space-age/README.md +3 -3
- data/tracks/elm/exercises/strain/README.md +3 -3
- data/tracks/elm/exercises/sublist/README.md +3 -3
- data/tracks/elm/exercises/sum-of-multiples/README.md +3 -3
- data/tracks/elm/exercises/triangle/README.md +3 -3
- data/tracks/elm/exercises/twelve-days/README.md +65 -0
- data/tracks/elm/exercises/twelve-days/TwelveDays.elm +1 -0
- data/tracks/elm/exercises/twelve-days/TwelveDays.example.elm +148 -0
- data/tracks/elm/exercises/twelve-days/elm-package.json +14 -0
- data/tracks/elm/exercises/twelve-days/tests/Tests.elm +130 -0
- data/tracks/elm/exercises/twelve-days/tests/elm-package.json +16 -0
- data/tracks/elm/exercises/word-count/README.md +3 -3
- data/tracks/elm/package-lock.json +2329 -0
- data/tracks/elm/package.json +6 -1
- data/tracks/erlang/config/exercise_readme.go.tmpl +42 -4
- data/tracks/erlang/exercises/accumulate/README.md +0 -3
- data/tracks/erlang/exercises/all-your-base/README.md +1 -2
- data/tracks/erlang/exercises/allergies/README.md +0 -1
- data/tracks/erlang/exercises/atbash-cipher/README.md +2 -1
- data/tracks/erlang/exercises/bank-account/README.md +0 -1
- data/tracks/erlang/exercises/beer-song/README.md +2 -2
- data/tracks/erlang/exercises/circular-buffer/README.md +13 -6
- data/tracks/erlang/exercises/collatz-conjecture/README.md +1 -1
- data/tracks/erlang/exercises/custom-set/README.md +0 -1
- data/tracks/erlang/exercises/etl/README.md +3 -1
- data/tracks/erlang/exercises/grade-school/README.md +0 -1
- data/tracks/erlang/exercises/grains/README.md +0 -1
- data/tracks/erlang/exercises/isogram/README.md +5 -7
- data/tracks/erlang/exercises/leap/README.md +1 -1
- data/tracks/erlang/exercises/luhn/README.md +7 -7
- data/tracks/erlang/exercises/meetup/README.md +16 -13
- data/tracks/erlang/exercises/nucleotide-count/README.md +8 -22
- data/tracks/erlang/exercises/pangram/README.md +7 -9
- data/tracks/erlang/exercises/parallel-letter-frequency/README.md +0 -1
- data/tracks/erlang/exercises/phone-number/README.md +4 -3
- data/tracks/erlang/exercises/raindrops/README.md +1 -1
- data/tracks/erlang/exercises/rna-transcription/README.md +2 -2
- data/tracks/erlang/exercises/roman-numerals/README.md +1 -1
- data/tracks/erlang/exercises/rotational-cipher/README.md +2 -1
- data/tracks/erlang/exercises/scrabble-score/README.md +3 -1
- data/tracks/erlang/exercises/sieve/README.md +26 -37
- data/tracks/erlang/exercises/space-age/README.md +1 -1
- data/tracks/erlang/exercises/spiral-matrix/README.md +2 -2
- data/tracks/erlang/exercises/sum-of-multiples/README.md +3 -6
- data/tracks/erlang/exercises/triangle/README.md +9 -6
- data/tracks/erlang/exercises/two-fer/README.md +48 -5
- data/tracks/erlang/exercises/word-count/README.md +1 -2
- data/tracks/erlang/exercises/zipper/README.md +1 -2
- data/tracks/go/config.json +11 -0
- data/tracks/go/exercises/bowling/cases_test.go +17 -2
- data/tracks/go/exercises/grep/.meta/gen.go +9 -7
- data/tracks/go/exercises/grep/cases_test.go +2 -2
- data/tracks/go/exercises/scale-generator/.meta/gen.go +59 -0
- data/tracks/go/exercises/scale-generator/README.md +76 -0
- data/tracks/go/exercises/scale-generator/cases_test.go +117 -0
- data/tracks/go/exercises/scale-generator/example.go +62 -0
- data/tracks/go/exercises/scale-generator/scale_generator_test.go +24 -0
- data/tracks/haskell/.travis.yml +16 -0
- data/tracks/haskell/config.json +9 -0
- data/tracks/haskell/config/exercise_readme.go.tmpl +53 -4
- data/tracks/haskell/exercises/all-your-base/README.md +0 -1
- data/tracks/haskell/exercises/alphametics/README.md +0 -1
- data/tracks/haskell/exercises/alphametics/examples/success-standard/src/Alphametics.hs +2 -2
- data/tracks/haskell/exercises/bank-account/README.md +0 -1
- data/tracks/haskell/exercises/bank-account/examples/success-standard/src/BankAccount.hs +1 -1
- data/tracks/haskell/exercises/connect/README.md +0 -1
- data/tracks/haskell/exercises/custom-set/README.md +0 -1
- data/tracks/haskell/exercises/dominoes/README.md +0 -1
- data/tracks/haskell/exercises/forth/README.md +0 -1
- data/tracks/haskell/exercises/go-counting/README.md +0 -1
- data/tracks/haskell/exercises/lens-person/README.md +0 -1
- data/tracks/haskell/exercises/list-ops/README.md +0 -1
- data/tracks/haskell/exercises/minesweeper/README.md +0 -1
- data/tracks/haskell/exercises/parallel-letter-frequency/README.md +0 -1
- data/tracks/haskell/exercises/sgf-parsing/README.md +0 -1
- data/tracks/haskell/exercises/sgf-parsing/examples/success-standard/src/Sgf.hs +2 -3
- data/tracks/haskell/exercises/sublist/README.md +0 -1
- data/tracks/haskell/exercises/transpose/README.md +119 -0
- data/tracks/haskell/exercises/transpose/examples/success-standard/package.yaml +16 -0
- data/tracks/haskell/exercises/transpose/examples/success-standard/src/Transpose.hs +16 -0
- data/tracks/haskell/exercises/transpose/package.yaml +20 -0
- data/tracks/haskell/exercises/transpose/src/Transpose.hs +4 -0
- data/tracks/haskell/exercises/transpose/stack.yaml +1 -0
- data/tracks/haskell/exercises/transpose/test/Tests.hs +181 -0
- data/tracks/haskell/exercises/zipper/README.md +0 -1
- data/tracks/java/config.json +38 -0
- data/tracks/java/exercises/atbash-cipher/.meta/version +1 -1
- data/tracks/java/exercises/collatz-conjecture/.meta/version +1 -1
- data/tracks/java/exercises/diffie-hellman/.meta/hints.md +3 -0
- data/tracks/java/exercises/diffie-hellman/.meta/src/reference/java/DiffieHellman.java +24 -0
- data/tracks/java/exercises/diffie-hellman/README.md +63 -0
- data/tracks/java/exercises/diffie-hellman/build.gradle +19 -0
- data/tracks/java/exercises/diffie-hellman/src/main/java/.keep +0 -0
- data/tracks/java/exercises/diffie-hellman/src/test/java/DiffieHellmanTest.java +98 -0
- data/tracks/java/exercises/error-handling/.meta/hints.md +35 -0
- data/tracks/java/exercises/error-handling/.meta/src/reference/java/CustomCheckedException.java +11 -0
- data/tracks/java/exercises/error-handling/.meta/src/reference/java/CustomUncheckedException.java +11 -0
- data/tracks/java/exercises/error-handling/.meta/src/reference/java/ErrorHandling.java +63 -0
- data/tracks/java/exercises/error-handling/README.md +24 -0
- data/tracks/java/exercises/error-handling/build.gradle +18 -0
- data/tracks/java/exercises/error-handling/src/main/java/CustomCheckedException.java +11 -0
- data/tracks/java/exercises/error-handling/src/main/java/CustomUncheckedException.java +11 -0
- data/tracks/java/exercises/error-handling/src/main/java/ErrorHandling.java +49 -0
- data/tracks/java/exercises/error-handling/src/test/java/ErrorHandlingTest.java +116 -0
- data/tracks/java/exercises/flatten-array/.meta/version +1 -1
- data/tracks/java/exercises/nth-prime/.meta/version +1 -1
- data/tracks/java/exercises/pig-latin/README.md +4 -4
- data/tracks/java/exercises/protein-translation/.meta/version +1 -1
- data/tracks/java/exercises/saddle-points/.meta/version +1 -1
- data/tracks/java/exercises/settings.gradle +3 -0
- data/tracks/java/exercises/variable-length-quantity/.meta/src/reference/java/VariableLengthQuantity.java +53 -0
- data/tracks/java/exercises/variable-length-quantity/.meta/version +1 -0
- data/tracks/java/exercises/variable-length-quantity/README.md +50 -0
- data/tracks/java/exercises/variable-length-quantity/build.gradle +18 -0
- data/tracks/java/exercises/variable-length-quantity/src/main/java/VariableLengthQuantity.java +12 -0
- data/tracks/java/exercises/variable-length-quantity/src/test/java/VariableLengthQuantityTest.java +265 -0
- data/tracks/java/exercises/word-count/.meta/version +1 -1
- data/tracks/javascript/.eslintignore +0 -6
- data/tracks/javascript/config.json +47 -0
- data/tracks/javascript/exercises/bowling/bowling.spec.js +105 -41
- data/tracks/javascript/exercises/bowling/example.js +112 -59
- data/tracks/javascript/exercises/custom-set/example-gen.js +4 -4
- data/tracks/javascript/exercises/flatten-array/example.js +6 -5
- data/tracks/javascript/exercises/flatten-array/flatten-array.spec.js +15 -15
- data/tracks/javascript/exercises/grade-school/example.js +6 -6
- data/tracks/javascript/exercises/kindergarten-garden/example.js +9 -9
- data/tracks/javascript/exercises/nth-prime/example.js +6 -6
- data/tracks/javascript/exercises/perfect-numbers/example.js +6 -2
- data/tracks/javascript/exercises/queen-attack/example.js +5 -5
- data/tracks/javascript/exercises/queen-attack/queen-attack.spec.js +11 -9
- data/tracks/javascript/exercises/rational-numbers/README.md +62 -0
- data/tracks/javascript/exercises/rational-numbers/example.js +69 -0
- data/tracks/javascript/exercises/rational-numbers/rational-numbers.spec.js +197 -0
- data/tracks/javascript/exercises/rectangles/README.md +91 -0
- data/tracks/javascript/exercises/rectangles/example.js +66 -0
- data/tracks/javascript/exercises/rectangles/rectangles.spec.js +108 -0
- data/tracks/javascript/exercises/rotational-cipher/README.md +64 -0
- data/tracks/javascript/exercises/rotational-cipher/example.js +24 -0
- data/tracks/javascript/exercises/rotational-cipher/rotational-cipher.spec.js +55 -0
- data/tracks/javascript/exercises/secret-handshake/example.js +1 -2
- data/tracks/javascript/exercises/secret-handshake/secret-handshake.spec.js +2 -1
- data/tracks/javascript/exercises/simple-linked-list/example.js +10 -6
- data/tracks/javascript/exercises/simple-linked-list/simple-linked-list.spec.js +6 -3
- data/tracks/javascript/exercises/variable-length-quantity/README.md +62 -0
- data/tracks/javascript/exercises/variable-length-quantity/example.js +51 -0
- data/tracks/javascript/exercises/variable-length-quantity/variable-length-quantity.spec.js +115 -0
- data/tracks/javascript/package.json +4 -2
- data/tracks/lfe/config/exercise_readme.go.tmpl +15 -4
- data/tracks/lfe/exercises/accumulate/README.md +0 -3
- data/tracks/lfe/exercises/allergies/README.md +0 -1
- data/tracks/lfe/exercises/atbash-cipher/README.md +2 -1
- data/tracks/lfe/exercises/bank-account/README.md +0 -1
- data/tracks/lfe/exercises/beer-song/README.md +2 -2
- data/tracks/lfe/exercises/binary/README.md +2 -0
- data/tracks/lfe/exercises/circular-buffer/README.md +13 -6
- data/tracks/lfe/exercises/etl/README.md +3 -1
- data/tracks/lfe/exercises/grade-school/README.md +0 -1
- data/tracks/lfe/exercises/grains/README.md +0 -1
- data/tracks/lfe/exercises/leap/README.md +1 -1
- data/tracks/lfe/exercises/luhn/README.md +7 -7
- data/tracks/lfe/exercises/meetup/README.md +16 -13
- data/tracks/lfe/exercises/nucleotide-count/README.md +8 -22
- data/tracks/lfe/exercises/parallel-letter-frequency/README.md +0 -1
- data/tracks/lfe/exercises/phone-number/README.md +4 -3
- data/tracks/lfe/exercises/rna-transcription/README.md +2 -2
- data/tracks/lfe/exercises/space-age/README.md +1 -1
- data/tracks/lfe/exercises/sum-of-multiples/README.md +3 -6
- data/tracks/lfe/exercises/trinary/README.md +1 -1
- data/tracks/lfe/exercises/word-count/README.md +1 -2
- data/tracks/objective-c/config.json +11 -0
- data/tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.h +9 -0
- data/tracks/objective-c/exercises/prime-factors/PrimeFactorsExample.m +24 -0
- data/tracks/objective-c/exercises/prime-factors/PrimeFactorsTest.m +67 -0
- data/tracks/objective-c/exercises/prime-factors/README.md +58 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
- data/tracks/ocaml/README.md +11 -2
- data/tracks/ocaml/docs/INSTALLATION.md +4 -4
- data/tracks/ocaml/docs/LEARNING.md +4 -2
- data/tracks/ocaml/docs/TESTS.md +7 -14
- data/tracks/ocaml/exercises/acronym/Makefile +4 -6
- data/tracks/ocaml/exercises/acronym/example.ml +2 -2
- data/tracks/ocaml/exercises/acronym/jbuild +11 -0
- data/tracks/ocaml/exercises/acronym/test.ml +1 -2
- data/tracks/ocaml/exercises/all-your-base/Makefile +4 -6
- data/tracks/ocaml/exercises/all-your-base/example.ml +1 -1
- data/tracks/ocaml/exercises/all-your-base/jbuild +11 -0
- data/tracks/ocaml/exercises/all-your-base/test.ml +1 -2
- data/tracks/ocaml/exercises/anagram/Makefile +4 -6
- data/tracks/ocaml/exercises/anagram/example.ml +2 -2
- data/tracks/ocaml/exercises/anagram/jbuild +11 -0
- data/tracks/ocaml/exercises/anagram/test.ml +2 -2
- data/tracks/ocaml/exercises/atbash-cipher/Makefile +4 -6
- data/tracks/ocaml/exercises/atbash-cipher/example.ml +1 -1
- data/tracks/ocaml/exercises/atbash-cipher/jbuild +11 -0
- data/tracks/ocaml/exercises/atbash-cipher/test.ml +1 -2
- data/tracks/ocaml/exercises/beer-song/Makefile +4 -6
- data/tracks/ocaml/exercises/beer-song/example.ml +3 -3
- data/tracks/ocaml/exercises/beer-song/jbuild +11 -0
- data/tracks/ocaml/exercises/beer-song/test.ml +3 -3
- data/tracks/ocaml/exercises/binary-search/Makefile +4 -6
- data/tracks/ocaml/exercises/binary-search/example.ml +1 -1
- data/tracks/ocaml/exercises/binary-search/jbuild +11 -0
- data/tracks/ocaml/exercises/binary-search/test.ml +1 -2
- data/tracks/ocaml/exercises/bob/Makefile +4 -6
- data/tracks/ocaml/exercises/bob/example.ml +2 -2
- data/tracks/ocaml/exercises/bob/jbuild +11 -0
- data/tracks/ocaml/exercises/bowling/Makefile +4 -6
- data/tracks/ocaml/exercises/bowling/bowling.mli +1 -1
- data/tracks/ocaml/exercises/bowling/example.ml +1 -1
- data/tracks/ocaml/exercises/bowling/jbuild +11 -0
- data/tracks/ocaml/exercises/bowling/test.ml +1 -1
- data/tracks/ocaml/exercises/bracket-push/Makefile +4 -6
- data/tracks/ocaml/exercises/bracket-push/example.ml +2 -2
- data/tracks/ocaml/exercises/bracket-push/jbuild +11 -0
- data/tracks/ocaml/exercises/bracket-push/test.ml +1 -1
- data/tracks/ocaml/exercises/change/Makefile +4 -6
- data/tracks/ocaml/exercises/change/example.ml +1 -1
- data/tracks/ocaml/exercises/change/jbuild +11 -0
- data/tracks/ocaml/exercises/change/test.ml +2 -2
- data/tracks/ocaml/exercises/connect/Makefile +4 -10
- data/tracks/ocaml/exercises/connect/example.ml +23 -17
- data/tracks/ocaml/exercises/connect/jbuild +11 -0
- data/tracks/ocaml/exercises/connect/test.ml +1 -1
- data/tracks/ocaml/exercises/custom-set/Makefile +4 -6
- data/tracks/ocaml/exercises/custom-set/jbuild +11 -0
- data/tracks/ocaml/exercises/difference-of-squares/Makefile +4 -6
- data/tracks/ocaml/exercises/difference-of-squares/example.ml +1 -1
- data/tracks/ocaml/exercises/difference-of-squares/jbuild +11 -0
- data/tracks/ocaml/exercises/difference-of-squares/test.ml +0 -1
- data/tracks/ocaml/exercises/dominoes/Makefile +4 -6
- data/tracks/ocaml/exercises/dominoes/example.ml +1 -1
- data/tracks/ocaml/exercises/dominoes/jbuild +11 -0
- data/tracks/ocaml/exercises/dominoes/test.ml +9 -4
- data/tracks/ocaml/exercises/etl/Makefile +4 -6
- data/tracks/ocaml/exercises/etl/example.ml +1 -1
- data/tracks/ocaml/exercises/etl/jbuild +11 -0
- data/tracks/ocaml/exercises/etl/test.ml +1 -3
- data/tracks/ocaml/exercises/forth/Makefile +4 -6
- data/tracks/ocaml/exercises/forth/example.ml +7 -4
- data/tracks/ocaml/exercises/forth/jbuild +11 -0
- data/tracks/ocaml/exercises/forth/test.ml +1 -1
- data/tracks/ocaml/exercises/grade-school/Makefile +4 -6
- data/tracks/ocaml/exercises/grade-school/example.ml +5 -6
- data/tracks/ocaml/exercises/grade-school/grade_school.mli +1 -6
- data/tracks/ocaml/exercises/grade-school/jbuild +11 -0
- data/tracks/ocaml/exercises/grade-school/test.ml +24 -56
- data/tracks/ocaml/exercises/hamming/Makefile +4 -6
- data/tracks/ocaml/exercises/hamming/example.ml +9 -2
- data/tracks/ocaml/exercises/hamming/jbuild +11 -0
- data/tracks/ocaml/exercises/hamming/test.ml +6 -6
- data/tracks/ocaml/exercises/hangman/Makefile +4 -6
- data/tracks/ocaml/exercises/hangman/example.ml +1 -1
- data/tracks/ocaml/exercises/hangman/jbuild +11 -0
- data/tracks/ocaml/exercises/hangman/test.ml +0 -1
- data/tracks/ocaml/exercises/hello-world/Makefile +4 -6
- data/tracks/ocaml/exercises/hello-world/jbuild +11 -0
- data/tracks/ocaml/exercises/hello-world/test.ml +1 -2
- data/tracks/ocaml/exercises/hexadecimal/Makefile +4 -6
- data/tracks/ocaml/exercises/hexadecimal/example.ml +2 -2
- data/tracks/ocaml/exercises/hexadecimal/jbuild +11 -0
- data/tracks/ocaml/exercises/hexadecimal/test.ml +1 -1
- data/tracks/ocaml/exercises/leap/Makefile +4 -6
- data/tracks/ocaml/exercises/leap/jbuild +11 -0
- data/tracks/ocaml/exercises/leap/test.ml +1 -2
- data/tracks/ocaml/exercises/list-ops/Makefile +4 -6
- data/tracks/ocaml/exercises/list-ops/jbuild +11 -0
- data/tracks/ocaml/exercises/list-ops/test.ml +2 -2
- data/tracks/ocaml/exercises/luhn/Makefile +4 -6
- data/tracks/ocaml/exercises/luhn/example.ml +2 -2
- data/tracks/ocaml/exercises/luhn/jbuild +11 -0
- data/tracks/ocaml/exercises/luhn/test.ml +1 -1
- data/tracks/ocaml/exercises/meetup/Makefile +4 -6
- data/tracks/ocaml/exercises/meetup/example.ml +1 -1
- data/tracks/ocaml/exercises/meetup/jbuild +11 -0
- data/tracks/ocaml/exercises/meetup/test.ml +1 -1
- data/tracks/ocaml/exercises/minesweeper/Makefile +4 -6
- data/tracks/ocaml/exercises/minesweeper/example.ml +2 -2
- data/tracks/ocaml/exercises/minesweeper/jbuild +11 -0
- data/tracks/ocaml/exercises/minesweeper/test.ml +1 -1
- data/tracks/ocaml/exercises/nucleotide-count/Makefile +4 -6
- data/tracks/ocaml/exercises/nucleotide-count/example.ml +1 -1
- data/tracks/ocaml/exercises/nucleotide-count/jbuild +11 -0
- data/tracks/ocaml/exercises/nucleotide-count/nucleotide_count.mli +1 -1
- data/tracks/ocaml/exercises/nucleotide-count/test.ml +1 -1
- data/tracks/ocaml/exercises/palindrome-products/Makefile +4 -6
- data/tracks/ocaml/exercises/palindrome-products/example.ml +5 -5
- data/tracks/ocaml/exercises/palindrome-products/jbuild +12 -0
- data/tracks/ocaml/exercises/pangram/Makefile +4 -6
- data/tracks/ocaml/exercises/pangram/example.ml +15 -6
- data/tracks/ocaml/exercises/pangram/jbuild +11 -0
- data/tracks/ocaml/exercises/pangram/test.ml +1 -2
- data/tracks/ocaml/exercises/phone-number/Makefile +4 -6
- data/tracks/ocaml/exercises/phone-number/example.ml +5 -5
- data/tracks/ocaml/exercises/phone-number/jbuild +11 -0
- data/tracks/ocaml/exercises/phone-number/test.ml +2 -2
- data/tracks/ocaml/exercises/prime-factors/Makefile +4 -6
- data/tracks/ocaml/exercises/prime-factors/example.ml +2 -2
- data/tracks/ocaml/exercises/prime-factors/jbuild +11 -0
- data/tracks/ocaml/exercises/prime-factors/test.ml +2 -2
- data/tracks/ocaml/exercises/raindrops/Makefile +4 -6
- data/tracks/ocaml/exercises/raindrops/example.ml +0 -2
- data/tracks/ocaml/exercises/raindrops/jbuild +11 -0
- data/tracks/ocaml/exercises/raindrops/test.ml +1 -2
- data/tracks/ocaml/exercises/react/Makefile +4 -6
- data/tracks/ocaml/exercises/react/example.ml +1 -1
- data/tracks/ocaml/exercises/react/jbuild +11 -0
- data/tracks/ocaml/exercises/react/test.ml +1 -1
- data/tracks/ocaml/exercises/rectangles/Makefile +4 -6
- data/tracks/ocaml/exercises/rectangles/jbuild +11 -0
- data/tracks/ocaml/exercises/rectangles/test.ml +1 -2
- data/tracks/ocaml/exercises/rna-transcription/Makefile +4 -6
- data/tracks/ocaml/exercises/rna-transcription/example.ml +1 -3
- data/tracks/ocaml/exercises/rna-transcription/jbuild +11 -0
- data/tracks/ocaml/exercises/rna-transcription/test.ml +1 -1
- data/tracks/ocaml/exercises/robot-name/Makefile +4 -6
- data/tracks/ocaml/exercises/robot-name/example.ml +2 -2
- data/tracks/ocaml/exercises/robot-name/jbuild +11 -0
- data/tracks/ocaml/exercises/robot-name/test.ml +6 -5
- data/tracks/ocaml/exercises/roman-numerals/Makefile +4 -6
- data/tracks/ocaml/exercises/roman-numerals/jbuild +11 -0
- data/tracks/ocaml/exercises/roman-numerals/test.ml +1 -2
- data/tracks/ocaml/exercises/run-length-encoding/Makefile +4 -6
- data/tracks/ocaml/exercises/run-length-encoding/example.ml +3 -3
- data/tracks/ocaml/exercises/run-length-encoding/jbuild +11 -0
- data/tracks/ocaml/exercises/run-length-encoding/test.ml +1 -1
- data/tracks/ocaml/exercises/say/Makefile +4 -6
- data/tracks/ocaml/exercises/say/example.ml +2 -2
- data/tracks/ocaml/exercises/say/jbuild +11 -0
- data/tracks/ocaml/exercises/say/test.ml +1 -1
- data/tracks/ocaml/exercises/space-age/Makefile +4 -6
- data/tracks/ocaml/exercises/space-age/example.ml +1 -1
- data/tracks/ocaml/exercises/space-age/jbuild +11 -0
- data/tracks/ocaml/exercises/space-age/test.ml +2 -2
- data/tracks/ocaml/exercises/triangle/Makefile +4 -6
- data/tracks/ocaml/exercises/triangle/example.ml +1 -1
- data/tracks/ocaml/exercises/triangle/jbuild +11 -0
- data/tracks/ocaml/exercises/triangle/test.ml +1 -1
- data/tracks/ocaml/exercises/word-count/Makefile +4 -6
- data/tracks/ocaml/exercises/word-count/example.ml +1 -1
- data/tracks/ocaml/exercises/word-count/jbuild +11 -0
- data/tracks/ocaml/exercises/word-count/test.ml +1 -1
- data/tracks/ocaml/exercises/word-count/word_count.mli +1 -1
- data/tracks/ocaml/exercises/zipper/Makefile +4 -6
- data/tracks/ocaml/exercises/zipper/example.ml +1 -1
- data/tracks/ocaml/exercises/zipper/jbuild +12 -0
- data/tracks/ocaml/exercises/zipper/test.ml +1 -1
- data/tracks/ocaml/exercises/zipper/tree.ml +1 -1
- data/tracks/ocaml/exercises/zipper/tree.mli +1 -1
- data/tracks/ocaml/exercises/zipper/zipper.mli +1 -1
- data/tracks/ocaml/tools/test-generator/Makefile +4 -13
- data/tracks/ocaml/tools/test-generator/jbuild +11 -0
- data/tracks/perl5/exercises/bob/.meta/exercise-data.yaml +9 -10
- data/tracks/perl5/exercises/bob/.meta/solutions/Bob.pm +7 -7
- data/tracks/perl5/exercises/bob/Bob.pm +1 -1
- data/tracks/perl5/exercises/bob/bob.t +81 -44
- data/tracks/perl5/exercises/clock/.meta/exercise-data.yaml +82 -0
- data/tracks/perl5/exercises/clock/.meta/solutions/Clock.pm +25 -52
- data/tracks/perl5/exercises/clock/Clock.pm +22 -0
- data/tracks/perl5/exercises/clock/clock.t +628 -92
- data/tracks/perl5/exercises/hello-world/.meta/exercise-data.yaml +1 -2
- data/tracks/perl5/exercises/hello-world/hello-world.t +4 -16
- data/tracks/perl5/exercises/leap/.meta/exercise-data.yaml +2 -3
- data/tracks/perl5/exercises/leap/leap.t +16 -21
- data/tracks/perl5/exercises/luhn/.meta/exercise-data.yaml +2 -2
- data/tracks/perl5/exercises/luhn/luhn.t +44 -30
- data/tracks/perl5/exercises/phone-number/.meta/exercise-data.yaml +3 -3
- data/tracks/perl5/exercises/phone-number/.meta/solutions/PhoneNumber.pm +1 -1
- data/tracks/perl5/exercises/phone-number/PhoneNumber.pm +1 -1
- data/tracks/perl5/exercises/phone-number/phone-number.t +59 -31
- data/tracks/perl6/exercises/all-your-base/.meta/exercise-data.yaml +1 -1
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +45 -45
- data/tracks/plsql/config/exercise_readme.go.tmpl +19 -4
- data/tracks/plsql/exercises/binary/README.md +2 -0
- data/tracks/plsql/exercises/grains/README.md +0 -1
- data/tracks/plsql/exercises/leap/README.md +1 -1
- data/tracks/plsql/exercises/rna-transcription/README.md +2 -2
- data/tracks/plsql/exercises/roman-numerals/README.md +1 -1
- data/tracks/prolog/config.json +30 -0
- data/tracks/prolog/config/maintainers.json +10 -0
- data/tracks/prolog/docs/INSTALLATION.md +4 -4
- data/tracks/prolog/docs/LEARNING.md +1 -0
- data/tracks/prolog/docs/TESTS.md +1 -1
- data/tracks/prolog/exercises/complex-numbers/README.md +38 -0
- data/tracks/prolog/exercises/complex-numbers/complex_numbers.example +14 -0
- data/tracks/prolog/exercises/complex-numbers/complex_numbers.pl +11 -0
- data/tracks/prolog/exercises/complex-numbers/complex_numbers_tests.plt +123 -0
- data/tracks/prolog/exercises/hello-world/README.md +1 -1
- data/tracks/prolog/exercises/hello-world/hello_world.pl +1 -1
- data/tracks/prolog/exercises/hello-world/hello_world_tests.plt +1 -1
- data/tracks/prolog/exercises/isogram/README.md +19 -0
- data/tracks/prolog/exercises/isogram/isogram.example +10 -0
- data/tracks/prolog/exercises/isogram/isogram.pl +1 -0
- data/tracks/prolog/exercises/isogram/isogram_tests.plt +39 -0
- data/tracks/prolog/exercises/queen-attack/README.md +32 -0
- data/tracks/prolog/exercises/queen-attack/queen_attack.example +12 -0
- data/tracks/prolog/exercises/queen-attack/queen_attack.pl +11 -0
- data/tracks/prolog/exercises/queen-attack/queen_attack_tests.plt +62 -0
- data/tracks/python/config/exercise_readme.go.tmpl +20 -1
- data/tracks/python/exercises/accumulate/README.md +20 -1
- data/tracks/python/exercises/acronym/README.md +20 -1
- data/tracks/python/exercises/all-your-base/README.md +20 -1
- data/tracks/python/exercises/allergies/README.md +20 -1
- data/tracks/python/exercises/alphametics/README.md +20 -1
- data/tracks/python/exercises/anagram/README.md +20 -1
- data/tracks/python/exercises/armstrong-numbers/README.md +20 -1
- data/tracks/python/exercises/atbash-cipher/README.md +20 -1
- data/tracks/python/exercises/beer-song/README.md +20 -1
- data/tracks/python/exercises/binary-search-tree/README.md +20 -1
- data/tracks/python/exercises/binary-search/README.md +20 -1
- data/tracks/python/exercises/binary/README.md +20 -1
- data/tracks/python/exercises/bob/README.md +20 -1
- data/tracks/python/exercises/book-store/README.md +20 -1
- data/tracks/python/exercises/bowling/README.md +20 -1
- data/tracks/python/exercises/bracket-push/README.md +20 -1
- data/tracks/python/exercises/change/README.md +20 -1
- data/tracks/python/exercises/circular-buffer/README.md +20 -1
- data/tracks/python/exercises/clock/README.md +20 -1
- data/tracks/python/exercises/collatz-conjecture/README.md +20 -1
- data/tracks/python/exercises/complex-numbers/README.md +20 -1
- data/tracks/python/exercises/connect/README.md +20 -1
- data/tracks/python/exercises/crypto-square/README.md +20 -1
- data/tracks/python/exercises/custom-set/README.md +20 -1
- data/tracks/python/exercises/diamond/README.md +20 -1
- data/tracks/python/exercises/difference-of-squares/README.md +20 -1
- data/tracks/python/exercises/diffie-hellman/README.md +20 -1
- data/tracks/python/exercises/dominoes/README.md +20 -1
- data/tracks/python/exercises/dot-dsl/README.md +20 -1
- data/tracks/python/exercises/error-handling/README.md +20 -1
- data/tracks/python/exercises/etl/README.md +20 -1
- data/tracks/python/exercises/flatten-array/README.md +20 -1
- data/tracks/python/exercises/food-chain/README.md +20 -1
- data/tracks/python/exercises/food-chain/example.py +9 -0
- data/tracks/python/exercises/food-chain/food_chain.py +1 -1
- data/tracks/python/exercises/food-chain/food_chain_test.py +79 -80
- data/tracks/python/exercises/forth/README.md +20 -1
- data/tracks/python/exercises/gigasecond/README.md +20 -1
- data/tracks/python/exercises/go-counting/README.md +20 -1
- data/tracks/python/exercises/grade-school/README.md +20 -1
- data/tracks/python/exercises/grains/README.md +20 -1
- data/tracks/python/exercises/grains/grains_test.py +1 -1
- data/tracks/python/exercises/grep/README.md +20 -1
- data/tracks/python/exercises/hamming/README.md +20 -1
- data/tracks/python/exercises/hello-world/README.md +20 -1
- data/tracks/python/exercises/hexadecimal/README.md +20 -1
- data/tracks/python/exercises/house/README.md +20 -1
- data/tracks/python/exercises/isbn-verifier/README.md +20 -1
- data/tracks/python/exercises/isogram/README.md +20 -1
- data/tracks/python/exercises/kindergarten-garden/README.md +20 -1
- data/tracks/python/exercises/largest-series-product/README.md +20 -1
- data/tracks/python/exercises/leap/README.md +20 -1
- data/tracks/python/exercises/linked-list/README.md +20 -1
- data/tracks/python/exercises/list-ops/README.md +20 -1
- data/tracks/python/exercises/luhn/README.md +20 -1
- data/tracks/python/exercises/markdown/README.md +20 -1
- data/tracks/python/exercises/matrix/README.md +20 -1
- data/tracks/python/exercises/meetup/README.md +20 -1
- data/tracks/python/exercises/minesweeper/README.md +20 -1
- data/tracks/python/exercises/nth-prime/README.md +20 -1
- data/tracks/python/exercises/nucleotide-count/README.md +20 -1
- data/tracks/python/exercises/ocr-numbers/README.md +20 -1
- data/tracks/python/exercises/octal/README.md +20 -1
- data/tracks/python/exercises/palindrome-products/README.md +20 -1
- data/tracks/python/exercises/pangram/README.md +20 -1
- data/tracks/python/exercises/parallel-letter-frequency/README.md +20 -1
- data/tracks/python/exercises/pascals-triangle/README.md +20 -1
- data/tracks/python/exercises/perfect-numbers/README.md +20 -1
- data/tracks/python/exercises/phone-number/README.md +20 -1
- data/tracks/python/exercises/pig-latin/README.md +24 -5
- data/tracks/python/exercises/point-mutations/README.md +20 -1
- data/tracks/python/exercises/poker/README.md +20 -1
- data/tracks/python/exercises/pov/README.md +20 -1
- data/tracks/python/exercises/prime-factors/README.md +20 -1
- data/tracks/python/exercises/protein-translation/README.md +20 -1
- data/tracks/python/exercises/proverb/README.md +20 -1
- data/tracks/python/exercises/pythagorean-triplet/README.md +20 -1
- data/tracks/python/exercises/queen-attack/README.md +20 -1
- data/tracks/python/exercises/queen-attack/example.py +16 -26
- data/tracks/python/exercises/queen-attack/queen_attack.py +5 -5
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +18 -49
- data/tracks/python/exercises/rail-fence-cipher/README.md +20 -1
- data/tracks/python/exercises/raindrops/README.md +20 -1
- data/tracks/python/exercises/rational-numbers/README.md +20 -1
- data/tracks/python/exercises/react/README.md +20 -1
- data/tracks/python/exercises/rectangles/README.md +20 -1
- data/tracks/python/exercises/reverse-string/README.md +20 -1
- data/tracks/python/exercises/rna-transcription/README.md +20 -1
- data/tracks/python/exercises/robot-name/README.md +20 -1
- data/tracks/python/exercises/robot-simulator/README.md +20 -1
- data/tracks/python/exercises/roman-numerals/README.md +20 -1
- data/tracks/python/exercises/rotational-cipher/README.md +20 -1
- data/tracks/python/exercises/run-length-encoding/README.md +20 -1
- data/tracks/python/exercises/saddle-points/README.md +20 -1
- data/tracks/python/exercises/say/README.md +20 -1
- data/tracks/python/exercises/scale-generator/README.md +20 -1
- data/tracks/python/exercises/scrabble-score/README.md +20 -1
- data/tracks/python/exercises/secret-handshake/README.md +20 -1
- data/tracks/python/exercises/series/README.md +20 -1
- data/tracks/python/exercises/sieve/README.md +20 -1
- data/tracks/python/exercises/simple-cipher/README.md +20 -1
- data/tracks/python/exercises/simple-linked-list/README.md +20 -1
- data/tracks/python/exercises/space-age/README.md +20 -1
- data/tracks/python/exercises/spiral-matrix/README.md +20 -1
- data/tracks/python/exercises/strain/README.md +20 -1
- data/tracks/python/exercises/sublist/README.md +20 -1
- data/tracks/python/exercises/sum-of-multiples/README.md +20 -1
- data/tracks/python/exercises/tournament/README.md +20 -1
- data/tracks/python/exercises/transpose/README.md +20 -1
- data/tracks/python/exercises/tree-building/README.md +20 -1
- data/tracks/python/exercises/triangle/README.md +20 -1
- data/tracks/python/exercises/trinary/README.md +20 -1
- data/tracks/python/exercises/twelve-days/README.md +20 -1
- data/tracks/python/exercises/two-bucket/README.md +21 -2
- data/tracks/python/exercises/two-fer/README.md +20 -1
- data/tracks/python/exercises/variable-length-quantity/README.md +20 -1
- data/tracks/python/exercises/word-count/README.md +20 -1
- data/tracks/python/exercises/word-search/README.md +20 -1
- data/tracks/python/exercises/wordy/README.md +20 -1
- data/tracks/python/exercises/zebra-puzzle/README.md +20 -1
- data/tracks/python/exercises/zipper/README.md +20 -1
- data/tracks/rust/_test/check-exercises.sh +3 -0
- data/tracks/rust/config.json +1 -1
- data/tracks/rust/exercises/collatz-conjecture/example.rs +3 -3
- data/tracks/rust/exercises/collatz-conjecture/src/lib.rs +2 -2
- data/tracks/rust/exercises/collatz-conjecture/tests/collatz-conjecture.rs +5 -5
- data/tracks/rust/exercises/nth-prime/example.rs +4 -4
- data/tracks/rust/exercises/nth-prime/src/lib.rs +3 -0
- data/tracks/rust/exercises/nth-prime/tests/nth-prime.rs +5 -5
- data/tracks/rust/exercises/perfect-numbers/example.rs +5 -5
- data/tracks/rust/exercises/perfect-numbers/src/lib.rs +1 -1
- data/tracks/rust/exercises/perfect-numbers/tests/perfect-numbers.rs +2 -2
- data/tracks/rust/exercises/reverse-string/src/lib.rs +2 -2
- data/tracks/scala/exercises/nth-prime/src/test/scala/NthPrimeTest.scala +2 -2
- data/tracks/scala/exercises/nucleotide-count/src/test/scala/NucleotideCountTest.scala +16 -16
- data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrNumbersTest.scala +6 -5
- data/tracks/scala/exercises/palindrome-products/src/test/scala/PalindromeProductsTest.scala +15 -19
- data/tracks/scala/exercises/pangram/src/test/scala/PangramTest.scala +10 -5
- data/tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala +47 -8
- data/tracks/scala/exercises/perfect-numbers/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/perfect-numbers/src/test/scala/PerfectNumbersTest.scala +17 -15
- data/tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala +26 -16
- data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +24 -24
- data/tracks/scala/exercises/prime-factors/src/test/scala/PrimefactorsTest.scala +9 -9
- data/tracks/scala/exercises/protein-translation/example.scala +5 -5
- data/tracks/scala/exercises/protein-translation/src/test/scala/ProteinTranslationTest.scala +91 -29
- data/tracks/scala/exercises/queen-attack/src/test/scala/QueenAttackTest.scala +20 -20
- data/tracks/scala/exercises/rail-fence-cipher/src/test/scala/RailFenceCipherTest.scala +15 -9
- data/tracks/scala/exercises/raindrops/src/test/scala/RaindropsTest.scala +2 -2
- data/tracks/scala/exercises/rna-transcription/src/test/scala/RnaTranscriptionTest.scala +8 -23
- data/tracks/scala/exercises/roman-numerals/src/test/scala/RomanNumeralsTest.scala +6 -1
- data/tracks/scala/testgen/src/main/scala/KindergartenGardenTestGenerator.scala +0 -6
- data/tracks/scala/testgen/src/main/scala/NthPrimeTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/NucleotideCountTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/OcrNumbersTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/PalindromeProductsTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/PangramsTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/PascalsTriangleTestGenerator.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/PerfectNumbersTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/PhoneNumberTestGenerator.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/PigLatinTestGenerator.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/PrimeFactorsTestGenerator.scala +6 -8
- data/tracks/scala/testgen/src/main/scala/QueenAttackTestGenerator.scala +24 -22
- data/tracks/scala/testgen/src/main/scala/RailFenceCipherTestGenerator.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/RaindropsTestGenerator.scala +2 -2
- data/tracks/scala/testgen/src/main/scala/RnaTranscriptionTestGenerator.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/RomanNumeralsTestGenerator.scala +2 -2
- data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +5 -0
- data/tracks/scheme/docs/RESOURCES.md +1 -0
- data/tracks/swift/.travis.yml +5 -0
- data/tracks/typescript/config.json +154 -1
- data/tracks/typescript/config/maintainers.json +10 -0
- data/tracks/typescript/exercises/allergies/README.md +62 -0
- data/tracks/typescript/exercises/allergies/allergies.example.ts +48 -0
- data/tracks/typescript/exercises/allergies/allergies.test.ts +113 -0
- data/tracks/typescript/exercises/allergies/allergies.ts +0 -0
- data/tracks/typescript/exercises/allergies/package.json +36 -0
- data/tracks/typescript/exercises/allergies/tsconfig.json +22 -0
- data/tracks/typescript/exercises/allergies/tslint.json +127 -0
- data/tracks/typescript/exercises/allergies/yarn.lock +2624 -0
- data/tracks/typescript/exercises/collatz-conjecture/README.md +59 -0
- data/tracks/typescript/exercises/collatz-conjecture/collatz-conjecture.example.ts +20 -0
- data/tracks/typescript/exercises/collatz-conjecture/collatz-conjecture.test.ts +33 -0
- data/tracks/typescript/exercises/collatz-conjecture/collatz-conjecture.ts +7 -0
- data/tracks/typescript/exercises/collatz-conjecture/package.json +36 -0
- data/tracks/typescript/exercises/collatz-conjecture/tsconfig.json +22 -0
- data/tracks/typescript/exercises/collatz-conjecture/tslint.json +127 -0
- data/tracks/typescript/exercises/collatz-conjecture/yarn.lock +2624 -0
- data/tracks/typescript/exercises/isogram/README.md +46 -0
- data/tracks/typescript/exercises/isogram/isogram.example.ts +31 -0
- data/tracks/typescript/exercises/isogram/isogram.test.ts +48 -0
- data/tracks/typescript/exercises/isogram/isogram.ts +7 -0
- data/tracks/typescript/exercises/isogram/package.json +36 -0
- data/tracks/typescript/exercises/isogram/tsconfig.json +22 -0
- data/tracks/typescript/exercises/isogram/tslint.json +127 -0
- data/tracks/typescript/exercises/isogram/yarn.lock +2624 -0
- data/tracks/typescript/exercises/matrix/README.md +73 -0
- data/tracks/typescript/exercises/matrix/matrix.example.ts +36 -0
- data/tracks/typescript/exercises/matrix/matrix.test.ts +43 -0
- data/tracks/typescript/exercises/matrix/matrix.ts +7 -0
- data/tracks/typescript/exercises/matrix/package.json +36 -0
- data/tracks/typescript/exercises/matrix/tsconfig.json +22 -0
- data/tracks/typescript/exercises/matrix/tslint.json +127 -0
- data/tracks/typescript/exercises/matrix/yarn.lock +2624 -0
- data/tracks/typescript/exercises/nucleotide-count/README.md +45 -0
- data/tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts +25 -0
- data/tracks/typescript/exercises/nucleotide-count/nucleotide-count.test.ts +48 -0
- data/tracks/typescript/exercises/nucleotide-count/nucleotide-count.ts +7 -0
- data/tracks/typescript/exercises/nucleotide-count/package.json +36 -0
- data/tracks/typescript/exercises/nucleotide-count/tsconfig.json +22 -0
- data/tracks/typescript/exercises/nucleotide-count/tslint.json +127 -0
- data/tracks/typescript/exercises/nucleotide-count/yarn.lock +2624 -0
- data/tracks/typescript/exercises/protein-translation/README.md +74 -0
- data/tracks/typescript/exercises/protein-translation/package.json +36 -0
- data/tracks/typescript/exercises/protein-translation/protein-translation.example.ts +61 -0
- data/tracks/typescript/exercises/protein-translation/protein-translation.test.ts +118 -0
- data/tracks/typescript/exercises/protein-translation/protein-translation.ts +7 -0
- data/tracks/typescript/exercises/protein-translation/tsconfig.json +22 -0
- data/tracks/typescript/exercises/protein-translation/tslint.json +127 -0
- data/tracks/typescript/exercises/protein-translation/yarn.lock +2624 -0
- data/tracks/typescript/exercises/reverse-string/README.md +39 -0
- data/tracks/typescript/exercises/reverse-string/package.json +36 -0
- data/tracks/typescript/exercises/reverse-string/reverse-string.example.ts +7 -0
- data/tracks/typescript/exercises/reverse-string/reverse-string.test.ts +28 -0
- data/tracks/typescript/exercises/reverse-string/reverse-string.ts +7 -0
- data/tracks/typescript/exercises/reverse-string/tsconfig.json +22 -0
- data/tracks/typescript/exercises/reverse-string/tslint.json +127 -0
- data/tracks/typescript/exercises/reverse-string/yarn.lock +2624 -0
- data/tracks/typescript/exercises/roman-numerals/README.md +75 -0
- data/tracks/typescript/exercises/roman-numerals/package.json +36 -0
- data/tracks/typescript/exercises/roman-numerals/roman-numerals.example.ts +32 -0
- data/tracks/typescript/exercises/roman-numerals/roman-numerals.test.ts +98 -0
- data/tracks/typescript/exercises/roman-numerals/roman-numerals.ts +7 -0
- data/tracks/typescript/exercises/roman-numerals/tsconfig.json +22 -0
- data/tracks/typescript/exercises/roman-numerals/tslint.json +127 -0
- data/tracks/typescript/exercises/roman-numerals/yarn.lock +2624 -0
- data/tracks/typescript/exercises/saddle-points/README.md +59 -0
- data/tracks/typescript/exercises/saddle-points/package.json +36 -0
- data/tracks/typescript/exercises/saddle-points/saddle-points.example.ts +35 -0
- data/tracks/typescript/exercises/saddle-points/saddle-points.test.ts +54 -0
- data/tracks/typescript/exercises/saddle-points/saddle-points.ts +7 -0
- data/tracks/typescript/exercises/saddle-points/tsconfig.json +22 -0
- data/tracks/typescript/exercises/saddle-points/tslint.json +127 -0
- data/tracks/typescript/exercises/saddle-points/yarn.lock +2624 -0
- data/tracks/typescript/exercises/twelve-days/README.md +61 -0
- data/tracks/typescript/exercises/twelve-days/package.json +36 -0
- data/tracks/typescript/exercises/twelve-days/tsconfig.json +22 -0
- data/tracks/typescript/exercises/twelve-days/tslint.json +127 -0
- data/tracks/typescript/exercises/twelve-days/twelve-days.example.ts +53 -0
- data/tracks/typescript/exercises/twelve-days/twelve-days.test.ts +80 -0
- data/tracks/typescript/exercises/twelve-days/twelve-days.ts +7 -0
- data/tracks/typescript/exercises/twelve-days/yarn.lock +2624 -0
- data/tracks/typescript/exercises/two-fer/README.md +45 -0
- data/tracks/typescript/exercises/two-fer/package.json +36 -0
- data/tracks/typescript/exercises/two-fer/tsconfig.json +22 -0
- data/tracks/typescript/exercises/two-fer/tslint.json +127 -0
- data/tracks/typescript/exercises/two-fer/two-fer.example.ts +7 -0
- data/tracks/typescript/exercises/two-fer/two-fer.test.ts +18 -0
- data/tracks/typescript/exercises/two-fer/two-fer.ts +7 -0
- data/tracks/typescript/exercises/two-fer/yarn.lock +2624 -0
- data/tracks/vbnet/config/exercise_readme.go.tmpl +5 -4
- data/tracks/vbnet/exercises/accumulate/README.md +0 -3
- data/tracks/vbnet/exercises/allergies/README.md +0 -1
- data/tracks/vbnet/exercises/atbash-cipher/README.md +2 -1
- data/tracks/vbnet/exercises/binary/README.md +2 -0
- data/tracks/vbnet/exercises/crypto-square/README.md +10 -8
- metadata +251 -47
- data/tracks/coffeescript/docs/EXERCISE_README_INSERT.md +0 -6
- data/tracks/coq/docs/EXERCISE_README_INSERT.md +0 -22
- data/tracks/cpp/docs/EXERCISE_README_INSERT.md +0 -30
- data/tracks/d/docs/EXERCISE_README_INSERT.md +0 -29
- data/tracks/ecmascript/docs/EXERCISE_README_INSERT.md +0 -28
- data/tracks/elm/exercises/accumulate/package.json +0 -14
- data/tracks/elm/exercises/allergies/package.json +0 -14
- data/tracks/elm/exercises/anagram/package.json +0 -14
- data/tracks/elm/exercises/atbash-cipher/package.json +0 -14
- data/tracks/elm/exercises/bob/package.json +0 -14
- data/tracks/elm/exercises/collatz-conjecture/package.json +0 -14
- data/tracks/elm/exercises/difference-of-squares/package.json +0 -14
- data/tracks/elm/exercises/etl/package.json +0 -14
- data/tracks/elm/exercises/gigasecond/package.json +0 -14
- data/tracks/elm/exercises/grade-school/package.json +0 -14
- data/tracks/elm/exercises/grains/package.json +0 -14
- data/tracks/elm/exercises/hamming/package.json +0 -14
- data/tracks/elm/exercises/hello-world/package.json +0 -14
- data/tracks/elm/exercises/isogram/package.json +0 -14
- data/tracks/elm/exercises/largest-series-product/package.json +0 -14
- data/tracks/elm/exercises/leap/package.json +0 -14
- data/tracks/elm/exercises/list-ops/package.json +0 -14
- data/tracks/elm/exercises/nucleotide-count/package.json +0 -14
- data/tracks/elm/exercises/pangram/package.json +0 -14
- data/tracks/elm/exercises/pascals-triangle/package.json +0 -14
- data/tracks/elm/exercises/phone-number/package.json +0 -14
- data/tracks/elm/exercises/raindrops/package.json +0 -14
- data/tracks/elm/exercises/rna-transcription/package.json +0 -14
- data/tracks/elm/exercises/robot-simulator/package.json +0 -14
- data/tracks/elm/exercises/roman-numerals/package.json +0 -14
- data/tracks/elm/exercises/run-length-encoding/package.json +0 -14
- data/tracks/elm/exercises/say/package.json +0 -14
- data/tracks/elm/exercises/scrabble-score/package.json +0 -14
- data/tracks/elm/exercises/series/package.json +0 -14
- data/tracks/elm/exercises/space-age/package.json +0 -14
- data/tracks/elm/exercises/strain/package.json +0 -14
- data/tracks/elm/exercises/sublist/package.json +0 -14
- data/tracks/elm/exercises/sum-of-multiples/package.json +0 -14
- data/tracks/elm/exercises/triangle/package.json +0 -14
- data/tracks/elm/exercises/word-count/package.json +0 -14
- data/tracks/erlang/docs/EXERCISE_README_INSERT.md +0 -41
- data/tracks/haskell/docs/EXERCISE_README_INSERT.md +0 -52
- data/tracks/lfe/docs/EXERCISE_README_INSERT.md +0 -14
- data/tracks/plsql/docs/EXERCISE_README_INSERT.md +0 -18
- data/tracks/vbnet/docs/EXERCISE_README_INSERT.md +0 -5
@@ -0,0 +1,17 @@
|
|
1
|
+
Implement a program that translates from English to Pig Latin.
|
2
|
+
|
3
|
+
Pig Latin is a made-up children's language that's intended to be
|
4
|
+
confusing. It obeys a few simple rules (below), but when it's spoken
|
5
|
+
quickly it's really difficult for non-children (and non-native speakers)
|
6
|
+
to understand.
|
7
|
+
|
8
|
+
- **Rule 1**: If a word begins with a vowel sound, add an "ay" sound to the end of the word. Please note that "xr" and "yt" at the beginning of a word make vowel sounds (e.g. "xray" -> "xrayay", "yttria" -> "yttriaay").
|
9
|
+
- **Rule 2**: If a word begins with a consonant sound, move it to the end of the word and then add an "ay" sound to the end of the word. Consonant sounds can be made up of multiple consonants, a.k.a. a consonant cluster (e.g. "chair" -> "airchay").
|
10
|
+
- **Rule 3**: If a word starts with a consonant sound followed by "qu", move it to the end of the word, and then add an "ay" sound to the end of the word (e.g. "square" -> "aresquay").
|
11
|
+
- **Rule 4**: If a word contains a "y" after a consonant cluster or as the second letter in a two letter word it makes a vowel sound (e.g. "rhythm" -> "ythmrhay", "my" -> "ymay").
|
12
|
+
|
13
|
+
There are a few more rules for edge cases, and there are regional
|
14
|
+
variants too.
|
15
|
+
|
16
|
+
See <http://en.wikipedia.org/wiki/Pig_latin> for more details.
|
17
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
CFLAGS = -std=c99
|
2
|
+
CFLAGS += -g
|
3
|
+
CFLAGS += -Wall
|
4
|
+
CFLAGS += -Wextra
|
5
|
+
CFLAGS += -pedantic
|
6
|
+
CFLAGS += -Werror
|
7
|
+
|
8
|
+
VFLAGS = --quiet
|
9
|
+
VFLAGS += --tool=memcheck
|
10
|
+
VFLAGS += --leak-check=full
|
11
|
+
VFLAGS += --error-exitcode=1
|
12
|
+
|
13
|
+
test: tests.out
|
14
|
+
@./tests.out
|
15
|
+
|
16
|
+
memcheck: tests.out
|
17
|
+
@valgrind $(VFLAGS) ./tests.out
|
18
|
+
@echo "Memory check passed"
|
19
|
+
|
20
|
+
clean:
|
21
|
+
rm -rf *.o *.out *.out.dSYM
|
22
|
+
|
23
|
+
tests.out: test/test_pig_latin.c src/pig_latin.c src/pig_latin.h
|
24
|
+
@echo Compiling $@
|
25
|
+
@cc $(CFLAGS) src/pig_latin.c test/vendor/unity.c test/test_pig_latin.c -o tests.out
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#include "pig_latin.h"
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <string.h>
|
5
|
+
#include <ctype.h>
|
6
|
+
#include <stdbool.h>
|
7
|
+
|
8
|
+
static bool is_vowel(const char letter)
|
9
|
+
{
|
10
|
+
return letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o'
|
11
|
+
|| letter == 'u';
|
12
|
+
}
|
13
|
+
|
14
|
+
static bool starts_with_vowel_sound(const char *input)
|
15
|
+
{
|
16
|
+
const char first_letter = tolower(input[0]);
|
17
|
+
const char sec_letter = tolower(input[1]);
|
18
|
+
|
19
|
+
return is_vowel(first_letter) || (first_letter == 'x' && sec_letter == 'r')
|
20
|
+
|| (first_letter == 'y' && sec_letter == 't');
|
21
|
+
}
|
22
|
+
|
23
|
+
static void count_words_and_chars(const char *input, size_t * words,
|
24
|
+
size_t * chars)
|
25
|
+
{
|
26
|
+
bool in_word = false;
|
27
|
+
while (*input) {
|
28
|
+
(*chars)++;
|
29
|
+
if (isalpha(*input++)) {
|
30
|
+
*words += in_word ? 0 : 1;
|
31
|
+
in_word = true;
|
32
|
+
} else {
|
33
|
+
in_word = false;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
static void strncpy_tolower(char *dst, const char *src, size_t n)
|
39
|
+
{
|
40
|
+
while ((n--) && (*dst++ = tolower(*src++))) ;
|
41
|
+
}
|
42
|
+
|
43
|
+
static void append_ay(char *translated)
|
44
|
+
{
|
45
|
+
*translated = 'a';
|
46
|
+
*(translated + 1) = 'y';
|
47
|
+
}
|
48
|
+
|
49
|
+
static bool starts_with(const char *input, const char *start_seq)
|
50
|
+
{
|
51
|
+
while (*start_seq)
|
52
|
+
if (tolower(*input++) != *start_seq++)
|
53
|
+
return false;
|
54
|
+
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
|
58
|
+
static void process_pig_logic(char *dst, const char *src, size_t word_len)
|
59
|
+
{
|
60
|
+
append_ay(dst + word_len);
|
61
|
+
|
62
|
+
if (starts_with_vowel_sound(src)) {
|
63
|
+
strncpy_tolower(dst, src, word_len);
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
size_t i = 0;
|
68
|
+
while (src[i]) {
|
69
|
+
if (is_vowel(tolower(src[i])))
|
70
|
+
break;
|
71
|
+
|
72
|
+
if (starts_with(&src[i + 1], "y")) {
|
73
|
+
i++;
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
|
77
|
+
if (starts_with(&src[i], "qu")) {
|
78
|
+
i += 2;
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
i++;
|
82
|
+
}
|
83
|
+
|
84
|
+
strncpy_tolower(dst, src + i, word_len - i);
|
85
|
+
strncpy_tolower(dst + (word_len - i), src, i);
|
86
|
+
}
|
87
|
+
|
88
|
+
char *translate(const char *phrase)
|
89
|
+
{
|
90
|
+
if (phrase == NULL)
|
91
|
+
return NULL;
|
92
|
+
|
93
|
+
size_t words = 0, chars = 0;
|
94
|
+
count_words_and_chars(phrase, &words, &chars);
|
95
|
+
if (chars == 0)
|
96
|
+
return NULL;
|
97
|
+
|
98
|
+
/* every word gets 'ay' at the end */
|
99
|
+
const size_t translated_len = chars + words * 2;
|
100
|
+
|
101
|
+
char *translated = malloc(translated_len + 1);
|
102
|
+
if (translated == NULL) {
|
103
|
+
fprintf(stderr, "Memory error!\n");
|
104
|
+
return NULL;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (words == 0)
|
108
|
+
return strcpy(translated, phrase);
|
109
|
+
|
110
|
+
char *tmp = translated;
|
111
|
+
while (words--) {
|
112
|
+
/* just copy non-alphas */
|
113
|
+
while (*phrase && !isalpha(*phrase))
|
114
|
+
*tmp++ = *phrase++;
|
115
|
+
|
116
|
+
size_t word_len = 0;
|
117
|
+
while (isalpha(phrase[word_len]))
|
118
|
+
word_len++;
|
119
|
+
|
120
|
+
process_pig_logic(tmp, phrase, word_len);
|
121
|
+
|
122
|
+
tmp += word_len + 2;
|
123
|
+
phrase += word_len;
|
124
|
+
}
|
125
|
+
translated[translated_len] = '\0';
|
126
|
+
|
127
|
+
return translated;
|
128
|
+
}
|
@@ -0,0 +1,239 @@
|
|
1
|
+
#include "vendor/unity.h"
|
2
|
+
#include "../src/pig_latin.h"
|
3
|
+
#include <stdlib.h>
|
4
|
+
|
5
|
+
void setUp(void)
|
6
|
+
{
|
7
|
+
}
|
8
|
+
|
9
|
+
void tearDown(void)
|
10
|
+
{
|
11
|
+
}
|
12
|
+
|
13
|
+
void test_word_beginning_with_a(void)
|
14
|
+
{
|
15
|
+
const char *phrase = "apple";
|
16
|
+
char *res = translate(phrase);
|
17
|
+
TEST_ASSERT_EQUAL_STRING("appleay", res);
|
18
|
+
free(res);
|
19
|
+
}
|
20
|
+
|
21
|
+
void test_word_beginning_with_e(void)
|
22
|
+
{
|
23
|
+
TEST_IGNORE(); // delete this line to run test
|
24
|
+
const char *phrase = "ear";
|
25
|
+
char *res = translate(phrase);
|
26
|
+
TEST_ASSERT_EQUAL_STRING("earay", res);
|
27
|
+
free(res);
|
28
|
+
}
|
29
|
+
|
30
|
+
void test_word_beginning_with_i(void)
|
31
|
+
{
|
32
|
+
TEST_IGNORE();
|
33
|
+
const char *phrase = "igloo";
|
34
|
+
char *res = translate(phrase);
|
35
|
+
TEST_ASSERT_EQUAL_STRING("iglooay", res);
|
36
|
+
free(res);
|
37
|
+
}
|
38
|
+
|
39
|
+
void test_word_beginning_with_o(void)
|
40
|
+
{
|
41
|
+
TEST_IGNORE();
|
42
|
+
const char *phrase = "object";
|
43
|
+
char *res = translate(phrase);
|
44
|
+
TEST_ASSERT_EQUAL_STRING("objectay", res);
|
45
|
+
free(res);
|
46
|
+
}
|
47
|
+
|
48
|
+
void test_word_beginning_with_u(void)
|
49
|
+
{
|
50
|
+
TEST_IGNORE();
|
51
|
+
const char *phrase = "under";
|
52
|
+
char *res = translate(phrase);
|
53
|
+
TEST_ASSERT_EQUAL_STRING("underay", res);
|
54
|
+
free(res);
|
55
|
+
}
|
56
|
+
|
57
|
+
void test_word_beginning_with_a_vowel_and_followed_by_a_qu(void)
|
58
|
+
{
|
59
|
+
TEST_IGNORE();
|
60
|
+
const char *phrase = "equal";
|
61
|
+
char *res = translate(phrase);
|
62
|
+
TEST_ASSERT_EQUAL_STRING("equalay", res);
|
63
|
+
free(res);
|
64
|
+
}
|
65
|
+
|
66
|
+
void test_word_beginning_with_p(void)
|
67
|
+
{
|
68
|
+
TEST_IGNORE();
|
69
|
+
const char *phrase = "pig";
|
70
|
+
char *res = translate(phrase);
|
71
|
+
TEST_ASSERT_EQUAL_STRING("igpay", res);
|
72
|
+
free(res);
|
73
|
+
}
|
74
|
+
|
75
|
+
void test_word_beginning_with_k(void)
|
76
|
+
{
|
77
|
+
TEST_IGNORE();
|
78
|
+
const char *phrase = "koala";
|
79
|
+
char *res = translate(phrase);
|
80
|
+
TEST_ASSERT_EQUAL_STRING("oalakay", res);
|
81
|
+
free(res);
|
82
|
+
}
|
83
|
+
|
84
|
+
void test_word_beginning_with_x(void)
|
85
|
+
{
|
86
|
+
TEST_IGNORE();
|
87
|
+
const char *phrase = "xenon";
|
88
|
+
char *res = translate(phrase);
|
89
|
+
TEST_ASSERT_EQUAL_STRING("enonxay", res);
|
90
|
+
free(res);
|
91
|
+
}
|
92
|
+
|
93
|
+
void test_word_beginning_with_q_without_a_following_u(void)
|
94
|
+
{
|
95
|
+
TEST_IGNORE();
|
96
|
+
const char *phrase = "qat";
|
97
|
+
char *res = translate(phrase);
|
98
|
+
TEST_ASSERT_EQUAL_STRING("atqay", res);
|
99
|
+
free(res);
|
100
|
+
}
|
101
|
+
|
102
|
+
void test_word_beginning_with_ch(void)
|
103
|
+
{
|
104
|
+
TEST_IGNORE();
|
105
|
+
const char *phrase = "chair";
|
106
|
+
char *res = translate(phrase);
|
107
|
+
TEST_ASSERT_EQUAL_STRING("airchay", res);
|
108
|
+
free(res);
|
109
|
+
}
|
110
|
+
|
111
|
+
void test_word_beginning_with_qu(void)
|
112
|
+
{
|
113
|
+
TEST_IGNORE();
|
114
|
+
const char *phrase = "queen";
|
115
|
+
char *res = translate(phrase);
|
116
|
+
TEST_ASSERT_EQUAL_STRING("eenquay", res);
|
117
|
+
free(res);
|
118
|
+
}
|
119
|
+
|
120
|
+
void test_word_beginning_with_qu_and_a_preceding_consonant(void)
|
121
|
+
{
|
122
|
+
TEST_IGNORE();
|
123
|
+
const char *phrase = "square";
|
124
|
+
char *res = translate(phrase);
|
125
|
+
TEST_ASSERT_EQUAL_STRING("aresquay", res);
|
126
|
+
free(res);
|
127
|
+
}
|
128
|
+
|
129
|
+
void test_word_beginning_with_th(void)
|
130
|
+
{
|
131
|
+
TEST_IGNORE();
|
132
|
+
const char *phrase = "therapy";
|
133
|
+
char *res = translate(phrase);
|
134
|
+
TEST_ASSERT_EQUAL_STRING("erapythay", res);
|
135
|
+
free(res);
|
136
|
+
}
|
137
|
+
|
138
|
+
void test_word_beginning_with_thr(void)
|
139
|
+
{
|
140
|
+
TEST_IGNORE();
|
141
|
+
const char *phrase = "thrush";
|
142
|
+
char *res = translate(phrase);
|
143
|
+
TEST_ASSERT_EQUAL_STRING("ushthray", res);
|
144
|
+
free(res);
|
145
|
+
}
|
146
|
+
|
147
|
+
void test_word_beginning_with_sch(void)
|
148
|
+
{
|
149
|
+
TEST_IGNORE();
|
150
|
+
const char *phrase = "school";
|
151
|
+
char *res = translate(phrase);
|
152
|
+
TEST_ASSERT_EQUAL_STRING("oolschay", res);
|
153
|
+
free(res);
|
154
|
+
}
|
155
|
+
|
156
|
+
void test_word_beginning_with_yt(void)
|
157
|
+
{
|
158
|
+
TEST_IGNORE();
|
159
|
+
const char *phrase = "yttria";
|
160
|
+
char *res = translate(phrase);
|
161
|
+
TEST_ASSERT_EQUAL_STRING("yttriaay", res);
|
162
|
+
free(res);
|
163
|
+
}
|
164
|
+
|
165
|
+
void test_word_beginning_with_xr(void)
|
166
|
+
{
|
167
|
+
TEST_IGNORE();
|
168
|
+
const char *phrase = "xray";
|
169
|
+
char *res = translate(phrase);
|
170
|
+
TEST_ASSERT_EQUAL_STRING("xrayay", res);
|
171
|
+
free(res);
|
172
|
+
}
|
173
|
+
|
174
|
+
void test_y_is_treated_like_a_consonant_at_the_beginning_of_a_word(void)
|
175
|
+
{
|
176
|
+
TEST_IGNORE();
|
177
|
+
const char *phrase = "yellow";
|
178
|
+
char *res = translate(phrase);
|
179
|
+
TEST_ASSERT_EQUAL_STRING("ellowyay", res);
|
180
|
+
free(res);
|
181
|
+
}
|
182
|
+
|
183
|
+
void test_y_is_treated_like_a_vowel_at_the_end_of_a_consonant_cluster(void)
|
184
|
+
{
|
185
|
+
TEST_IGNORE();
|
186
|
+
const char *phrase = "rhythm";
|
187
|
+
char *res = translate(phrase);
|
188
|
+
TEST_ASSERT_EQUAL_STRING("ythmrhay", res);
|
189
|
+
free(res);
|
190
|
+
}
|
191
|
+
|
192
|
+
void test_y_as_second_letter_in_two_letter_word(void)
|
193
|
+
{
|
194
|
+
TEST_IGNORE();
|
195
|
+
const char *phrase = "my";
|
196
|
+
char *res = translate(phrase);
|
197
|
+
TEST_ASSERT_EQUAL_STRING("ymay", res);
|
198
|
+
free(res);
|
199
|
+
}
|
200
|
+
|
201
|
+
void test_a_whole_phrase(void)
|
202
|
+
{
|
203
|
+
TEST_IGNORE();
|
204
|
+
const char *phrase = "quick fast run";
|
205
|
+
char *res = translate(phrase);
|
206
|
+
TEST_ASSERT_EQUAL_STRING("ickquay astfay unray", res);
|
207
|
+
free(res);
|
208
|
+
}
|
209
|
+
|
210
|
+
int main(void)
|
211
|
+
{
|
212
|
+
UnityBegin("test/test_pig_latin.c");
|
213
|
+
|
214
|
+
RUN_TEST(test_word_beginning_with_a);
|
215
|
+
RUN_TEST(test_word_beginning_with_e);
|
216
|
+
RUN_TEST(test_word_beginning_with_i);
|
217
|
+
RUN_TEST(test_word_beginning_with_o);
|
218
|
+
RUN_TEST(test_word_beginning_with_u);
|
219
|
+
RUN_TEST(test_word_beginning_with_a_vowel_and_followed_by_a_qu);
|
220
|
+
RUN_TEST(test_word_beginning_with_p);
|
221
|
+
RUN_TEST(test_word_beginning_with_k);
|
222
|
+
RUN_TEST(test_word_beginning_with_x);
|
223
|
+
RUN_TEST(test_word_beginning_with_q_without_a_following_u);
|
224
|
+
RUN_TEST(test_word_beginning_with_ch);
|
225
|
+
RUN_TEST(test_word_beginning_with_qu);
|
226
|
+
RUN_TEST(test_word_beginning_with_qu_and_a_preceding_consonant);
|
227
|
+
RUN_TEST(test_word_beginning_with_th);
|
228
|
+
RUN_TEST(test_word_beginning_with_thr);
|
229
|
+
RUN_TEST(test_word_beginning_with_sch);
|
230
|
+
RUN_TEST(test_word_beginning_with_yt);
|
231
|
+
RUN_TEST(test_word_beginning_with_xr);
|
232
|
+
RUN_TEST(test_y_is_treated_like_a_consonant_at_the_beginning_of_a_word);
|
233
|
+
RUN_TEST(test_y_is_treated_like_a_vowel_at_the_end_of_a_consonant_cluster);
|
234
|
+
RUN_TEST(test_y_as_second_letter_in_two_letter_word);
|
235
|
+
RUN_TEST(test_a_whole_phrase);
|
236
|
+
|
237
|
+
UnityEnd();
|
238
|
+
return 0;
|
239
|
+
}
|
@@ -0,0 +1,1300 @@
|
|
1
|
+
/* =========================================================================
|
2
|
+
Unity Project - A Test Framework for C
|
3
|
+
Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
|
+
[Released under MIT License. Please refer to license.txt for details]
|
5
|
+
============================================================================ */
|
6
|
+
|
7
|
+
#include "unity.h"
|
8
|
+
#include <stddef.h>
|
9
|
+
|
10
|
+
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
|
11
|
+
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
|
12
|
+
/// return prematurely if we are already in failure or ignore state
|
13
|
+
#define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
|
14
|
+
#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); }
|
15
|
+
|
16
|
+
struct _Unity Unity;
|
17
|
+
|
18
|
+
const char UnityStrOk[] = "OK";
|
19
|
+
const char UnityStrPass[] = "PASS";
|
20
|
+
const char UnityStrFail[] = "FAIL";
|
21
|
+
const char UnityStrIgnore[] = "IGNORE";
|
22
|
+
const char UnityStrNull[] = "NULL";
|
23
|
+
const char UnityStrSpacer[] = ". ";
|
24
|
+
const char UnityStrExpected[] = " Expected ";
|
25
|
+
const char UnityStrWas[] = " Was ";
|
26
|
+
const char UnityStrTo[] = " To ";
|
27
|
+
const char UnityStrElement[] = " Element ";
|
28
|
+
const char UnityStrByte[] = " Byte ";
|
29
|
+
const char UnityStrMemory[] = " Memory Mismatch.";
|
30
|
+
const char UnityStrDelta[] = " Values Not Within Delta ";
|
31
|
+
const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
|
32
|
+
const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
|
33
|
+
const char UnityStrNullPointerForActual[] = " Actual pointer was NULL";
|
34
|
+
const char UnityStrNot[] = "Not ";
|
35
|
+
const char UnityStrInf[] = "Infinity";
|
36
|
+
const char UnityStrNegInf[] = "Negative Infinity";
|
37
|
+
const char UnityStrNaN[] = "NaN";
|
38
|
+
const char UnityStrDet[] = "Determinate";
|
39
|
+
const char UnityStrErrFloat[] = "Unity Floating Point Disabled";
|
40
|
+
const char UnityStrErrDouble[] = "Unity Double Precision Disabled";
|
41
|
+
const char UnityStrErr64[] = "Unity 64-bit Support Disabled";
|
42
|
+
const char UnityStrBreaker[] = "-----------------------";
|
43
|
+
const char UnityStrResultsTests[] = " Tests ";
|
44
|
+
const char UnityStrResultsFailures[] = " Failures ";
|
45
|
+
const char UnityStrResultsIgnored[] = " Ignored ";
|
46
|
+
|
47
|
+
#ifndef UNITY_EXCLUDE_FLOAT
|
48
|
+
// Dividing by these constants produces +/- infinity.
|
49
|
+
// The rationale is given in UnityAssertFloatIsInf's body.
|
50
|
+
static const _UF f_zero = 0.0f;
|
51
|
+
#ifndef UNITY_EXCLUDE_DOUBLE
|
52
|
+
static const _UD d_zero = 0.0;
|
53
|
+
#endif
|
54
|
+
#endif
|
55
|
+
|
56
|
+
// compiler-generic print formatting masks
|
57
|
+
const _U_UINT UnitySizeMask[] =
|
58
|
+
{
|
59
|
+
255u, // 0xFF
|
60
|
+
65535u, // 0xFFFF
|
61
|
+
65535u,
|
62
|
+
4294967295u, // 0xFFFFFFFF
|
63
|
+
4294967295u,
|
64
|
+
4294967295u,
|
65
|
+
4294967295u
|
66
|
+
#ifdef UNITY_SUPPORT_64
|
67
|
+
,0xFFFFFFFFFFFFFFFF
|
68
|
+
#endif
|
69
|
+
};
|
70
|
+
|
71
|
+
void UnityPrintFail(void);
|
72
|
+
void UnityPrintOk(void);
|
73
|
+
|
74
|
+
//-----------------------------------------------
|
75
|
+
// Pretty Printers & Test Result Output Handlers
|
76
|
+
//-----------------------------------------------
|
77
|
+
|
78
|
+
void UnityPrint(const char* string)
|
79
|
+
{
|
80
|
+
const char* pch = string;
|
81
|
+
|
82
|
+
if (pch != NULL)
|
83
|
+
{
|
84
|
+
while (*pch)
|
85
|
+
{
|
86
|
+
// printable characters plus CR & LF are printed
|
87
|
+
if ((*pch <= 126) && (*pch >= 32))
|
88
|
+
{
|
89
|
+
UNITY_OUTPUT_CHAR(*pch);
|
90
|
+
}
|
91
|
+
//write escaped carriage returns
|
92
|
+
else if (*pch == 13)
|
93
|
+
{
|
94
|
+
UNITY_OUTPUT_CHAR('\\');
|
95
|
+
UNITY_OUTPUT_CHAR('r');
|
96
|
+
}
|
97
|
+
//write escaped line feeds
|
98
|
+
else if (*pch == 10)
|
99
|
+
{
|
100
|
+
UNITY_OUTPUT_CHAR('\\');
|
101
|
+
UNITY_OUTPUT_CHAR('n');
|
102
|
+
}
|
103
|
+
// unprintable characters are shown as codes
|
104
|
+
else
|
105
|
+
{
|
106
|
+
UNITY_OUTPUT_CHAR('\\');
|
107
|
+
UnityPrintNumberHex((_U_UINT)*pch, 2);
|
108
|
+
}
|
109
|
+
pch++;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
void UnityPrintLen(const char* string, const _UU32 length);
|
115
|
+
void UnityPrintLen(const char* string, const _UU32 length)
|
116
|
+
{
|
117
|
+
const char* pch = string;
|
118
|
+
|
119
|
+
if (pch != NULL)
|
120
|
+
{
|
121
|
+
while (*pch && (_UU32)(pch - string) < length)
|
122
|
+
{
|
123
|
+
// printable characters plus CR & LF are printed
|
124
|
+
if ((*pch <= 126) && (*pch >= 32))
|
125
|
+
{
|
126
|
+
UNITY_OUTPUT_CHAR(*pch);
|
127
|
+
}
|
128
|
+
//write escaped carriage returns
|
129
|
+
else if (*pch == 13)
|
130
|
+
{
|
131
|
+
UNITY_OUTPUT_CHAR('\\');
|
132
|
+
UNITY_OUTPUT_CHAR('r');
|
133
|
+
}
|
134
|
+
//write escaped line feeds
|
135
|
+
else if (*pch == 10)
|
136
|
+
{
|
137
|
+
UNITY_OUTPUT_CHAR('\\');
|
138
|
+
UNITY_OUTPUT_CHAR('n');
|
139
|
+
}
|
140
|
+
// unprintable characters are shown as codes
|
141
|
+
else
|
142
|
+
{
|
143
|
+
UNITY_OUTPUT_CHAR('\\');
|
144
|
+
UnityPrintNumberHex((_U_UINT)*pch, 2);
|
145
|
+
}
|
146
|
+
pch++;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
//-----------------------------------------------
|
152
|
+
void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
|
153
|
+
{
|
154
|
+
if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
|
155
|
+
{
|
156
|
+
UnityPrintNumber(number);
|
157
|
+
}
|
158
|
+
else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
|
159
|
+
{
|
160
|
+
UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
|
161
|
+
}
|
162
|
+
else
|
163
|
+
{
|
164
|
+
UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
//-----------------------------------------------
|
169
|
+
/// basically do an itoa using as little ram as possible
|
170
|
+
void UnityPrintNumber(const _U_SINT number_to_print)
|
171
|
+
{
|
172
|
+
_U_SINT divisor = 1;
|
173
|
+
_U_SINT next_divisor;
|
174
|
+
_U_UINT number;
|
175
|
+
|
176
|
+
if (number_to_print == (1l << (UNITY_LONG_WIDTH-1)))
|
177
|
+
{
|
178
|
+
//The largest representable negative number
|
179
|
+
UNITY_OUTPUT_CHAR('-');
|
180
|
+
number = (1ul << (UNITY_LONG_WIDTH-1));
|
181
|
+
}
|
182
|
+
else if (number_to_print < 0)
|
183
|
+
{
|
184
|
+
//Some other negative number
|
185
|
+
UNITY_OUTPUT_CHAR('-');
|
186
|
+
number = (_U_UINT)(-number_to_print);
|
187
|
+
}
|
188
|
+
else
|
189
|
+
{
|
190
|
+
//Positive number
|
191
|
+
number = (_U_UINT)number_to_print;
|
192
|
+
}
|
193
|
+
|
194
|
+
// figure out initial divisor
|
195
|
+
while (number / divisor > 9)
|
196
|
+
{
|
197
|
+
next_divisor = divisor * 10;
|
198
|
+
if (next_divisor > divisor)
|
199
|
+
divisor = next_divisor;
|
200
|
+
else
|
201
|
+
break;
|
202
|
+
}
|
203
|
+
|
204
|
+
// now mod and print, then divide divisor
|
205
|
+
do
|
206
|
+
{
|
207
|
+
UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
|
208
|
+
divisor /= 10;
|
209
|
+
}
|
210
|
+
while (divisor > 0);
|
211
|
+
}
|
212
|
+
|
213
|
+
//-----------------------------------------------
|
214
|
+
/// basically do an itoa using as little ram as possible
|
215
|
+
void UnityPrintNumberUnsigned(const _U_UINT number)
|
216
|
+
{
|
217
|
+
_U_UINT divisor = 1;
|
218
|
+
_U_UINT next_divisor;
|
219
|
+
|
220
|
+
// figure out initial divisor
|
221
|
+
while (number / divisor > 9)
|
222
|
+
{
|
223
|
+
next_divisor = divisor * 10;
|
224
|
+
if (next_divisor > divisor)
|
225
|
+
divisor = next_divisor;
|
226
|
+
else
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
|
230
|
+
// now mod and print, then divide divisor
|
231
|
+
do
|
232
|
+
{
|
233
|
+
UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
|
234
|
+
divisor /= 10;
|
235
|
+
}
|
236
|
+
while (divisor > 0);
|
237
|
+
}
|
238
|
+
|
239
|
+
//-----------------------------------------------
|
240
|
+
void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
|
241
|
+
{
|
242
|
+
_U_UINT nibble;
|
243
|
+
char nibbles = nibbles_to_print;
|
244
|
+
UNITY_OUTPUT_CHAR('0');
|
245
|
+
UNITY_OUTPUT_CHAR('x');
|
246
|
+
|
247
|
+
while (nibbles > 0)
|
248
|
+
{
|
249
|
+
nibble = (number >> (--nibbles << 2)) & 0x0000000F;
|
250
|
+
if (nibble <= 9)
|
251
|
+
{
|
252
|
+
UNITY_OUTPUT_CHAR((char)('0' + nibble));
|
253
|
+
}
|
254
|
+
else
|
255
|
+
{
|
256
|
+
UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
//-----------------------------------------------
|
262
|
+
void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
|
263
|
+
{
|
264
|
+
_U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
|
265
|
+
_US32 i;
|
266
|
+
|
267
|
+
for (i = 0; i < UNITY_INT_WIDTH; i++)
|
268
|
+
{
|
269
|
+
if (current_bit & mask)
|
270
|
+
{
|
271
|
+
if (current_bit & number)
|
272
|
+
{
|
273
|
+
UNITY_OUTPUT_CHAR('1');
|
274
|
+
}
|
275
|
+
else
|
276
|
+
{
|
277
|
+
UNITY_OUTPUT_CHAR('0');
|
278
|
+
}
|
279
|
+
}
|
280
|
+
else
|
281
|
+
{
|
282
|
+
UNITY_OUTPUT_CHAR('X');
|
283
|
+
}
|
284
|
+
current_bit = current_bit >> 1;
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
//-----------------------------------------------
|
289
|
+
#ifdef UNITY_FLOAT_VERBOSE
|
290
|
+
#include <string.h>
|
291
|
+
void UnityPrintFloat(_UF number)
|
292
|
+
{
|
293
|
+
char TempBuffer[32];
|
294
|
+
sprintf(TempBuffer, "%.6f", number);
|
295
|
+
UnityPrint(TempBuffer);
|
296
|
+
}
|
297
|
+
#endif
|
298
|
+
|
299
|
+
//-----------------------------------------------
|
300
|
+
|
301
|
+
void UnityPrintFail(void);
|
302
|
+
void UnityPrintFail(void)
|
303
|
+
{
|
304
|
+
UnityPrint(UnityStrFail);
|
305
|
+
}
|
306
|
+
|
307
|
+
void UnityPrintOk(void);
|
308
|
+
void UnityPrintOk(void)
|
309
|
+
{
|
310
|
+
UnityPrint(UnityStrOk);
|
311
|
+
}
|
312
|
+
|
313
|
+
//-----------------------------------------------
|
314
|
+
static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line);
|
315
|
+
static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
316
|
+
{
|
317
|
+
#ifndef UNITY_FIXTURES
|
318
|
+
UnityPrint(file);
|
319
|
+
UNITY_OUTPUT_CHAR(':');
|
320
|
+
UnityPrintNumber((_U_SINT)line);
|
321
|
+
UNITY_OUTPUT_CHAR(':');
|
322
|
+
UnityPrint(Unity.CurrentTestName);
|
323
|
+
UNITY_OUTPUT_CHAR(':');
|
324
|
+
#else
|
325
|
+
UNITY_UNUSED(file);
|
326
|
+
UNITY_UNUSED(line);
|
327
|
+
#endif
|
328
|
+
}
|
329
|
+
|
330
|
+
//-----------------------------------------------
|
331
|
+
static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line);
|
332
|
+
static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
|
333
|
+
{
|
334
|
+
#ifndef UNITY_FIXTURES
|
335
|
+
UnityTestResultsBegin(Unity.TestFile, line);
|
336
|
+
#else
|
337
|
+
UNITY_UNUSED(line);
|
338
|
+
#endif
|
339
|
+
UnityPrint(UnityStrFail);
|
340
|
+
UNITY_OUTPUT_CHAR(':');
|
341
|
+
}
|
342
|
+
|
343
|
+
//-----------------------------------------------
|
344
|
+
void UnityConcludeTest(void)
|
345
|
+
{
|
346
|
+
if (Unity.CurrentTestIgnored)
|
347
|
+
{
|
348
|
+
Unity.TestIgnores++;
|
349
|
+
}
|
350
|
+
else if (!Unity.CurrentTestFailed)
|
351
|
+
{
|
352
|
+
UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
|
353
|
+
UnityPrint(UnityStrPass);
|
354
|
+
}
|
355
|
+
else
|
356
|
+
{
|
357
|
+
Unity.TestFailures++;
|
358
|
+
}
|
359
|
+
|
360
|
+
Unity.CurrentTestFailed = 0;
|
361
|
+
Unity.CurrentTestIgnored = 0;
|
362
|
+
UNITY_PRINT_EOL;
|
363
|
+
}
|
364
|
+
|
365
|
+
//-----------------------------------------------
|
366
|
+
static void UnityAddMsgIfSpecified(const char* msg);
|
367
|
+
static void UnityAddMsgIfSpecified(const char* msg)
|
368
|
+
{
|
369
|
+
if (msg)
|
370
|
+
{
|
371
|
+
UnityPrint(UnityStrSpacer);
|
372
|
+
UnityPrint(msg);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
//-----------------------------------------------
|
377
|
+
static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual);
|
378
|
+
static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
|
379
|
+
{
|
380
|
+
UnityPrint(UnityStrExpected);
|
381
|
+
if (expected != NULL)
|
382
|
+
{
|
383
|
+
UNITY_OUTPUT_CHAR('\'');
|
384
|
+
UnityPrint(expected);
|
385
|
+
UNITY_OUTPUT_CHAR('\'');
|
386
|
+
}
|
387
|
+
else
|
388
|
+
{
|
389
|
+
UnityPrint(UnityStrNull);
|
390
|
+
}
|
391
|
+
UnityPrint(UnityStrWas);
|
392
|
+
if (actual != NULL)
|
393
|
+
{
|
394
|
+
UNITY_OUTPUT_CHAR('\'');
|
395
|
+
UnityPrint(actual);
|
396
|
+
UNITY_OUTPUT_CHAR('\'');
|
397
|
+
}
|
398
|
+
else
|
399
|
+
{
|
400
|
+
UnityPrint(UnityStrNull);
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
//-----------------------------------------------
|
405
|
+
static void UnityPrintExpectedAndActualStringsLen(const char* expected, const char* actual, const _UU32 length)
|
406
|
+
{
|
407
|
+
UnityPrint(UnityStrExpected);
|
408
|
+
if (expected != NULL)
|
409
|
+
{
|
410
|
+
UNITY_OUTPUT_CHAR('\'');
|
411
|
+
UnityPrintLen(expected, length);
|
412
|
+
UNITY_OUTPUT_CHAR('\'');
|
413
|
+
}
|
414
|
+
else
|
415
|
+
{
|
416
|
+
UnityPrint(UnityStrNull);
|
417
|
+
}
|
418
|
+
UnityPrint(UnityStrWas);
|
419
|
+
if (actual != NULL)
|
420
|
+
{
|
421
|
+
UNITY_OUTPUT_CHAR('\'');
|
422
|
+
UnityPrintLen(actual, length);
|
423
|
+
UNITY_OUTPUT_CHAR('\'');
|
424
|
+
}
|
425
|
+
else
|
426
|
+
{
|
427
|
+
UnityPrint(UnityStrNull);
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
//-----------------------------------------------
|
434
|
+
// Assertion & Control Helpers
|
435
|
+
//-----------------------------------------------
|
436
|
+
|
437
|
+
static int UnityCheckArraysForNull(UNITY_PTR_ATTRIBUTE const void* expected, UNITY_PTR_ATTRIBUTE const void* actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
|
438
|
+
{
|
439
|
+
//return true if they are both NULL
|
440
|
+
if ((expected == NULL) && (actual == NULL))
|
441
|
+
return 1;
|
442
|
+
|
443
|
+
//throw error if just expected is NULL
|
444
|
+
if (expected == NULL)
|
445
|
+
{
|
446
|
+
UnityTestResultsFailBegin(lineNumber);
|
447
|
+
UnityPrint(UnityStrNullPointerForExpected);
|
448
|
+
UnityAddMsgIfSpecified(msg);
|
449
|
+
UNITY_FAIL_AND_BAIL;
|
450
|
+
}
|
451
|
+
|
452
|
+
//throw error if just actual is NULL
|
453
|
+
if (actual == NULL)
|
454
|
+
{
|
455
|
+
UnityTestResultsFailBegin(lineNumber);
|
456
|
+
UnityPrint(UnityStrNullPointerForActual);
|
457
|
+
UnityAddMsgIfSpecified(msg);
|
458
|
+
UNITY_FAIL_AND_BAIL;
|
459
|
+
}
|
460
|
+
|
461
|
+
//return false if neither is NULL
|
462
|
+
return 0;
|
463
|
+
}
|
464
|
+
|
465
|
+
//-----------------------------------------------
|
466
|
+
// Assertion Functions
|
467
|
+
//-----------------------------------------------
|
468
|
+
|
469
|
+
void UnityAssertBits(const _U_SINT mask,
|
470
|
+
const _U_SINT expected,
|
471
|
+
const _U_SINT actual,
|
472
|
+
const char* msg,
|
473
|
+
const UNITY_LINE_TYPE lineNumber)
|
474
|
+
{
|
475
|
+
UNITY_SKIP_EXECUTION;
|
476
|
+
|
477
|
+
if ((mask & expected) != (mask & actual))
|
478
|
+
{
|
479
|
+
UnityTestResultsFailBegin(lineNumber);
|
480
|
+
UnityPrint(UnityStrExpected);
|
481
|
+
UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
|
482
|
+
UnityPrint(UnityStrWas);
|
483
|
+
UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
|
484
|
+
UnityAddMsgIfSpecified(msg);
|
485
|
+
UNITY_FAIL_AND_BAIL;
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
//-----------------------------------------------
|
490
|
+
void UnityAssertEqualNumber(const _U_SINT expected,
|
491
|
+
const _U_SINT actual,
|
492
|
+
const char* msg,
|
493
|
+
const UNITY_LINE_TYPE lineNumber,
|
494
|
+
const UNITY_DISPLAY_STYLE_T style)
|
495
|
+
{
|
496
|
+
UNITY_SKIP_EXECUTION;
|
497
|
+
|
498
|
+
if (expected != actual)
|
499
|
+
{
|
500
|
+
UnityTestResultsFailBegin(lineNumber);
|
501
|
+
UnityPrint(UnityStrExpected);
|
502
|
+
UnityPrintNumberByStyle(expected, style);
|
503
|
+
UnityPrint(UnityStrWas);
|
504
|
+
UnityPrintNumberByStyle(actual, style);
|
505
|
+
UnityAddMsgIfSpecified(msg);
|
506
|
+
UNITY_FAIL_AND_BAIL;
|
507
|
+
}
|
508
|
+
}
|
509
|
+
|
510
|
+
//-----------------------------------------------
|
511
|
+
void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected,
|
512
|
+
UNITY_PTR_ATTRIBUTE const void* actual,
|
513
|
+
const _UU32 num_elements,
|
514
|
+
const char* msg,
|
515
|
+
const UNITY_LINE_TYPE lineNumber,
|
516
|
+
const UNITY_DISPLAY_STYLE_T style)
|
517
|
+
{
|
518
|
+
_UU32 elements = num_elements;
|
519
|
+
UNITY_PTR_ATTRIBUTE const void* ptr_exp = (UNITY_PTR_ATTRIBUTE const void*)expected;
|
520
|
+
UNITY_PTR_ATTRIBUTE const void* ptr_act = (UNITY_PTR_ATTRIBUTE const void*)actual;
|
521
|
+
|
522
|
+
UNITY_SKIP_EXECUTION;
|
523
|
+
|
524
|
+
if (elements == 0)
|
525
|
+
{
|
526
|
+
UnityTestResultsFailBegin(lineNumber);
|
527
|
+
UnityPrint(UnityStrPointless);
|
528
|
+
UnityAddMsgIfSpecified(msg);
|
529
|
+
UNITY_FAIL_AND_BAIL;
|
530
|
+
}
|
531
|
+
|
532
|
+
if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE const void*)expected, (UNITY_PTR_ATTRIBUTE const void*)actual, lineNumber, msg) == 1)
|
533
|
+
return;
|
534
|
+
|
535
|
+
// If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
|
536
|
+
// as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
|
537
|
+
// variants do not. Therefore remove this flag.
|
538
|
+
switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
|
539
|
+
{
|
540
|
+
case UNITY_DISPLAY_STYLE_HEX8:
|
541
|
+
case UNITY_DISPLAY_STYLE_INT8:
|
542
|
+
case UNITY_DISPLAY_STYLE_UINT8:
|
543
|
+
while (elements--)
|
544
|
+
{
|
545
|
+
if (*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act)
|
546
|
+
{
|
547
|
+
UnityTestResultsFailBegin(lineNumber);
|
548
|
+
UnityPrint(UnityStrElement);
|
549
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
550
|
+
UnityPrint(UnityStrExpected);
|
551
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_exp, style);
|
552
|
+
UnityPrint(UnityStrWas);
|
553
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US8*)ptr_act, style);
|
554
|
+
UnityAddMsgIfSpecified(msg);
|
555
|
+
UNITY_FAIL_AND_BAIL;
|
556
|
+
}
|
557
|
+
ptr_exp = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_exp + 1);
|
558
|
+
ptr_act = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_act + 1);
|
559
|
+
}
|
560
|
+
break;
|
561
|
+
case UNITY_DISPLAY_STYLE_HEX16:
|
562
|
+
case UNITY_DISPLAY_STYLE_INT16:
|
563
|
+
case UNITY_DISPLAY_STYLE_UINT16:
|
564
|
+
while (elements--)
|
565
|
+
{
|
566
|
+
if (*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act)
|
567
|
+
{
|
568
|
+
UnityTestResultsFailBegin(lineNumber);
|
569
|
+
UnityPrint(UnityStrElement);
|
570
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
571
|
+
UnityPrint(UnityStrExpected);
|
572
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp, style);
|
573
|
+
UnityPrint(UnityStrWas);
|
574
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act, style);
|
575
|
+
UnityAddMsgIfSpecified(msg);
|
576
|
+
UNITY_FAIL_AND_BAIL;
|
577
|
+
}
|
578
|
+
ptr_exp = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_exp + 2);
|
579
|
+
ptr_act = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_act + 2);
|
580
|
+
}
|
581
|
+
break;
|
582
|
+
#ifdef UNITY_SUPPORT_64
|
583
|
+
case UNITY_DISPLAY_STYLE_HEX64:
|
584
|
+
case UNITY_DISPLAY_STYLE_INT64:
|
585
|
+
case UNITY_DISPLAY_STYLE_UINT64:
|
586
|
+
while (elements--)
|
587
|
+
{
|
588
|
+
if (*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act)
|
589
|
+
{
|
590
|
+
UnityTestResultsFailBegin(lineNumber);
|
591
|
+
UnityPrint(UnityStrElement);
|
592
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
593
|
+
UnityPrint(UnityStrExpected);
|
594
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp, style);
|
595
|
+
UnityPrint(UnityStrWas);
|
596
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act, style);
|
597
|
+
UnityAddMsgIfSpecified(msg);
|
598
|
+
UNITY_FAIL_AND_BAIL;
|
599
|
+
}
|
600
|
+
ptr_exp = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_exp + 8);
|
601
|
+
ptr_act = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_act + 8);
|
602
|
+
}
|
603
|
+
break;
|
604
|
+
#endif
|
605
|
+
default:
|
606
|
+
while (elements--)
|
607
|
+
{
|
608
|
+
if (*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act)
|
609
|
+
{
|
610
|
+
UnityTestResultsFailBegin(lineNumber);
|
611
|
+
UnityPrint(UnityStrElement);
|
612
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
613
|
+
UnityPrint(UnityStrExpected);
|
614
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp, style);
|
615
|
+
UnityPrint(UnityStrWas);
|
616
|
+
UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act, style);
|
617
|
+
UnityAddMsgIfSpecified(msg);
|
618
|
+
UNITY_FAIL_AND_BAIL;
|
619
|
+
}
|
620
|
+
ptr_exp = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_exp + 4);
|
621
|
+
ptr_act = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_act + 4);
|
622
|
+
}
|
623
|
+
break;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
//-----------------------------------------------
|
628
|
+
#ifndef UNITY_EXCLUDE_FLOAT
|
629
|
+
void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
|
630
|
+
UNITY_PTR_ATTRIBUTE const _UF* actual,
|
631
|
+
const _UU32 num_elements,
|
632
|
+
const char* msg,
|
633
|
+
const UNITY_LINE_TYPE lineNumber)
|
634
|
+
{
|
635
|
+
_UU32 elements = num_elements;
|
636
|
+
UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
|
637
|
+
UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
|
638
|
+
_UF diff, tol;
|
639
|
+
|
640
|
+
UNITY_SKIP_EXECUTION;
|
641
|
+
|
642
|
+
if (elements == 0)
|
643
|
+
{
|
644
|
+
UnityTestResultsFailBegin(lineNumber);
|
645
|
+
UnityPrint(UnityStrPointless);
|
646
|
+
UnityAddMsgIfSpecified(msg);
|
647
|
+
UNITY_FAIL_AND_BAIL;
|
648
|
+
}
|
649
|
+
|
650
|
+
if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE const void*)expected, (UNITY_PTR_ATTRIBUTE const void*)actual, lineNumber, msg) == 1)
|
651
|
+
return;
|
652
|
+
|
653
|
+
while (elements--)
|
654
|
+
{
|
655
|
+
diff = *ptr_expected - *ptr_actual;
|
656
|
+
if (diff < 0.0f)
|
657
|
+
diff = 0.0f - diff;
|
658
|
+
tol = UNITY_FLOAT_PRECISION * *ptr_expected;
|
659
|
+
if (tol < 0.0f)
|
660
|
+
tol = 0.0f - tol;
|
661
|
+
|
662
|
+
//This first part of this condition will catch any NaN or Infinite values
|
663
|
+
if ((diff * 0.0f != 0.0f) || (diff > tol))
|
664
|
+
{
|
665
|
+
UnityTestResultsFailBegin(lineNumber);
|
666
|
+
UnityPrint(UnityStrElement);
|
667
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
668
|
+
#ifdef UNITY_FLOAT_VERBOSE
|
669
|
+
UnityPrint(UnityStrExpected);
|
670
|
+
UnityPrintFloat(*ptr_expected);
|
671
|
+
UnityPrint(UnityStrWas);
|
672
|
+
UnityPrintFloat(*ptr_actual);
|
673
|
+
#else
|
674
|
+
UnityPrint(UnityStrDelta);
|
675
|
+
#endif
|
676
|
+
UnityAddMsgIfSpecified(msg);
|
677
|
+
UNITY_FAIL_AND_BAIL;
|
678
|
+
}
|
679
|
+
ptr_expected++;
|
680
|
+
ptr_actual++;
|
681
|
+
}
|
682
|
+
}
|
683
|
+
|
684
|
+
//-----------------------------------------------
|
685
|
+
void UnityAssertFloatsWithin(const _UF delta,
|
686
|
+
const _UF expected,
|
687
|
+
const _UF actual,
|
688
|
+
const char* msg,
|
689
|
+
const UNITY_LINE_TYPE lineNumber)
|
690
|
+
{
|
691
|
+
_UF diff = actual - expected;
|
692
|
+
_UF pos_delta = delta;
|
693
|
+
|
694
|
+
UNITY_SKIP_EXECUTION;
|
695
|
+
|
696
|
+
if (diff < 0.0f)
|
697
|
+
{
|
698
|
+
diff = 0.0f - diff;
|
699
|
+
}
|
700
|
+
if (pos_delta < 0.0f)
|
701
|
+
{
|
702
|
+
pos_delta = 0.0f - pos_delta;
|
703
|
+
}
|
704
|
+
|
705
|
+
//This first part of this condition will catch any NaN or Infinite values
|
706
|
+
if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
|
707
|
+
{
|
708
|
+
UnityTestResultsFailBegin(lineNumber);
|
709
|
+
#ifdef UNITY_FLOAT_VERBOSE
|
710
|
+
UnityPrint(UnityStrExpected);
|
711
|
+
UnityPrintFloat(expected);
|
712
|
+
UnityPrint(UnityStrWas);
|
713
|
+
UnityPrintFloat(actual);
|
714
|
+
#else
|
715
|
+
UnityPrint(UnityStrDelta);
|
716
|
+
#endif
|
717
|
+
UnityAddMsgIfSpecified(msg);
|
718
|
+
UNITY_FAIL_AND_BAIL;
|
719
|
+
}
|
720
|
+
}
|
721
|
+
|
722
|
+
//-----------------------------------------------
|
723
|
+
void UnityAssertFloatSpecial(const _UF actual,
|
724
|
+
const char* msg,
|
725
|
+
const UNITY_LINE_TYPE lineNumber,
|
726
|
+
const UNITY_FLOAT_TRAIT_T style)
|
727
|
+
{
|
728
|
+
const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
|
729
|
+
_U_SINT should_be_trait = ((_U_SINT)style & 1);
|
730
|
+
_U_SINT is_trait = !should_be_trait;
|
731
|
+
_U_SINT trait_index = style >> 1;
|
732
|
+
|
733
|
+
UNITY_SKIP_EXECUTION;
|
734
|
+
|
735
|
+
switch(style)
|
736
|
+
{
|
737
|
+
//To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
|
738
|
+
//We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
|
739
|
+
case UNITY_FLOAT_IS_INF:
|
740
|
+
case UNITY_FLOAT_IS_NOT_INF:
|
741
|
+
is_trait = ((1.0f / f_zero) == actual) ? 1 : 0;
|
742
|
+
break;
|
743
|
+
case UNITY_FLOAT_IS_NEG_INF:
|
744
|
+
case UNITY_FLOAT_IS_NOT_NEG_INF:
|
745
|
+
is_trait = ((-1.0f / f_zero) == actual) ? 1 : 0;
|
746
|
+
break;
|
747
|
+
|
748
|
+
//NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
|
749
|
+
case UNITY_FLOAT_IS_NAN:
|
750
|
+
case UNITY_FLOAT_IS_NOT_NAN:
|
751
|
+
is_trait = (actual == actual) ? 0 : 1;
|
752
|
+
break;
|
753
|
+
|
754
|
+
//A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
|
755
|
+
case UNITY_FLOAT_IS_DET:
|
756
|
+
case UNITY_FLOAT_IS_NOT_DET:
|
757
|
+
if ( (actual != actual) || ((1.0f / f_zero) == actual) || ((-1.0f / f_zero) == actual) )
|
758
|
+
is_trait = 0;
|
759
|
+
else
|
760
|
+
is_trait = 1;
|
761
|
+
break;
|
762
|
+
default:
|
763
|
+
;
|
764
|
+
}
|
765
|
+
|
766
|
+
if (is_trait != should_be_trait)
|
767
|
+
{
|
768
|
+
UnityTestResultsFailBegin(lineNumber);
|
769
|
+
UnityPrint(UnityStrExpected);
|
770
|
+
if (!should_be_trait)
|
771
|
+
UnityPrint(UnityStrNot);
|
772
|
+
UnityPrint(trait_names[trait_index]);
|
773
|
+
UnityPrint(UnityStrWas);
|
774
|
+
#ifdef UNITY_FLOAT_VERBOSE
|
775
|
+
UnityPrintFloat(actual);
|
776
|
+
#else
|
777
|
+
if (should_be_trait)
|
778
|
+
UnityPrint(UnityStrNot);
|
779
|
+
UnityPrint(trait_names[trait_index]);
|
780
|
+
#endif
|
781
|
+
UnityAddMsgIfSpecified(msg);
|
782
|
+
UNITY_FAIL_AND_BAIL;
|
783
|
+
}
|
784
|
+
}
|
785
|
+
|
786
|
+
#endif //not UNITY_EXCLUDE_FLOAT
|
787
|
+
|
788
|
+
//-----------------------------------------------
|
789
|
+
#ifndef UNITY_EXCLUDE_DOUBLE
|
790
|
+
void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
|
791
|
+
UNITY_PTR_ATTRIBUTE const _UD* actual,
|
792
|
+
const _UU32 num_elements,
|
793
|
+
const char* msg,
|
794
|
+
const UNITY_LINE_TYPE lineNumber)
|
795
|
+
{
|
796
|
+
_UU32 elements = num_elements;
|
797
|
+
UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
|
798
|
+
UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
|
799
|
+
_UD diff, tol;
|
800
|
+
|
801
|
+
UNITY_SKIP_EXECUTION;
|
802
|
+
|
803
|
+
if (elements == 0)
|
804
|
+
{
|
805
|
+
UnityTestResultsFailBegin(lineNumber);
|
806
|
+
UnityPrint(UnityStrPointless);
|
807
|
+
UnityAddMsgIfSpecified(msg);
|
808
|
+
UNITY_FAIL_AND_BAIL;
|
809
|
+
}
|
810
|
+
|
811
|
+
if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
|
812
|
+
return;
|
813
|
+
|
814
|
+
while (elements--)
|
815
|
+
{
|
816
|
+
diff = *ptr_expected - *ptr_actual;
|
817
|
+
if (diff < 0.0)
|
818
|
+
diff = 0.0 - diff;
|
819
|
+
tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
|
820
|
+
if (tol < 0.0)
|
821
|
+
tol = 0.0 - tol;
|
822
|
+
|
823
|
+
//This first part of this condition will catch any NaN or Infinite values
|
824
|
+
if ((diff * 0.0 != 0.0) || (diff > tol))
|
825
|
+
{
|
826
|
+
UnityTestResultsFailBegin(lineNumber);
|
827
|
+
UnityPrint(UnityStrElement);
|
828
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
829
|
+
#ifdef UNITY_DOUBLE_VERBOSE
|
830
|
+
UnityPrint(UnityStrExpected);
|
831
|
+
UnityPrintFloat((float)(*ptr_expected));
|
832
|
+
UnityPrint(UnityStrWas);
|
833
|
+
UnityPrintFloat((float)(*ptr_actual));
|
834
|
+
#else
|
835
|
+
UnityPrint(UnityStrDelta);
|
836
|
+
#endif
|
837
|
+
UnityAddMsgIfSpecified(msg);
|
838
|
+
UNITY_FAIL_AND_BAIL;
|
839
|
+
}
|
840
|
+
ptr_expected++;
|
841
|
+
ptr_actual++;
|
842
|
+
}
|
843
|
+
}
|
844
|
+
|
845
|
+
//-----------------------------------------------
|
846
|
+
void UnityAssertDoublesWithin(const _UD delta,
|
847
|
+
const _UD expected,
|
848
|
+
const _UD actual,
|
849
|
+
const char* msg,
|
850
|
+
const UNITY_LINE_TYPE lineNumber)
|
851
|
+
{
|
852
|
+
_UD diff = actual - expected;
|
853
|
+
_UD pos_delta = delta;
|
854
|
+
|
855
|
+
UNITY_SKIP_EXECUTION;
|
856
|
+
|
857
|
+
if (diff < 0.0)
|
858
|
+
{
|
859
|
+
diff = 0.0 - diff;
|
860
|
+
}
|
861
|
+
if (pos_delta < 0.0)
|
862
|
+
{
|
863
|
+
pos_delta = 0.0 - pos_delta;
|
864
|
+
}
|
865
|
+
|
866
|
+
//This first part of this condition will catch any NaN or Infinite values
|
867
|
+
if ((diff * 0.0 != 0.0) || (pos_delta < diff))
|
868
|
+
{
|
869
|
+
UnityTestResultsFailBegin(lineNumber);
|
870
|
+
#ifdef UNITY_DOUBLE_VERBOSE
|
871
|
+
UnityPrint(UnityStrExpected);
|
872
|
+
UnityPrintFloat((float)expected);
|
873
|
+
UnityPrint(UnityStrWas);
|
874
|
+
UnityPrintFloat((float)actual);
|
875
|
+
#else
|
876
|
+
UnityPrint(UnityStrDelta);
|
877
|
+
#endif
|
878
|
+
UnityAddMsgIfSpecified(msg);
|
879
|
+
UNITY_FAIL_AND_BAIL;
|
880
|
+
}
|
881
|
+
}
|
882
|
+
|
883
|
+
//-----------------------------------------------
|
884
|
+
|
885
|
+
void UnityAssertDoubleSpecial(const _UD actual,
|
886
|
+
const char* msg,
|
887
|
+
const UNITY_LINE_TYPE lineNumber,
|
888
|
+
const UNITY_FLOAT_TRAIT_T style)
|
889
|
+
{
|
890
|
+
const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
|
891
|
+
_U_SINT should_be_trait = ((_U_SINT)style & 1);
|
892
|
+
_U_SINT is_trait = !should_be_trait;
|
893
|
+
_U_SINT trait_index = style >> 1;
|
894
|
+
|
895
|
+
UNITY_SKIP_EXECUTION;
|
896
|
+
|
897
|
+
switch(style)
|
898
|
+
{
|
899
|
+
//To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
|
900
|
+
//We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
|
901
|
+
case UNITY_FLOAT_IS_INF:
|
902
|
+
case UNITY_FLOAT_IS_NOT_INF:
|
903
|
+
is_trait = ((1.0 / d_zero) == actual) ? 1 : 0;
|
904
|
+
break;
|
905
|
+
case UNITY_FLOAT_IS_NEG_INF:
|
906
|
+
case UNITY_FLOAT_IS_NOT_NEG_INF:
|
907
|
+
is_trait = ((-1.0 / d_zero) == actual) ? 1 : 0;
|
908
|
+
break;
|
909
|
+
|
910
|
+
//NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
|
911
|
+
case UNITY_FLOAT_IS_NAN:
|
912
|
+
case UNITY_FLOAT_IS_NOT_NAN:
|
913
|
+
is_trait = (actual == actual) ? 0 : 1;
|
914
|
+
break;
|
915
|
+
|
916
|
+
//A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
|
917
|
+
case UNITY_FLOAT_IS_DET:
|
918
|
+
case UNITY_FLOAT_IS_NOT_DET:
|
919
|
+
if ( (actual != actual) || ((1.0 / d_zero) == actual) || ((-1.0 / d_zero) == actual) )
|
920
|
+
is_trait = 0;
|
921
|
+
else
|
922
|
+
is_trait = 1;
|
923
|
+
break;
|
924
|
+
default:
|
925
|
+
;
|
926
|
+
}
|
927
|
+
|
928
|
+
if (is_trait != should_be_trait)
|
929
|
+
{
|
930
|
+
UnityTestResultsFailBegin(lineNumber);
|
931
|
+
UnityPrint(UnityStrExpected);
|
932
|
+
if (!should_be_trait)
|
933
|
+
UnityPrint(UnityStrNot);
|
934
|
+
UnityPrint(trait_names[trait_index]);
|
935
|
+
UnityPrint(UnityStrWas);
|
936
|
+
#ifdef UNITY_DOUBLE_VERBOSE
|
937
|
+
UnityPrintFloat(actual);
|
938
|
+
#else
|
939
|
+
if (should_be_trait)
|
940
|
+
UnityPrint(UnityStrNot);
|
941
|
+
UnityPrint(trait_names[trait_index]);
|
942
|
+
#endif
|
943
|
+
UnityAddMsgIfSpecified(msg);
|
944
|
+
UNITY_FAIL_AND_BAIL;
|
945
|
+
}
|
946
|
+
}
|
947
|
+
|
948
|
+
|
949
|
+
#endif // not UNITY_EXCLUDE_DOUBLE
|
950
|
+
|
951
|
+
//-----------------------------------------------
|
952
|
+
void UnityAssertNumbersWithin( const _U_SINT delta,
|
953
|
+
const _U_SINT expected,
|
954
|
+
const _U_SINT actual,
|
955
|
+
const char* msg,
|
956
|
+
const UNITY_LINE_TYPE lineNumber,
|
957
|
+
const UNITY_DISPLAY_STYLE_T style)
|
958
|
+
{
|
959
|
+
UNITY_SKIP_EXECUTION;
|
960
|
+
|
961
|
+
if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
|
962
|
+
{
|
963
|
+
if (actual > expected)
|
964
|
+
Unity.CurrentTestFailed = ((actual - expected) > delta);
|
965
|
+
else
|
966
|
+
Unity.CurrentTestFailed = ((expected - actual) > delta);
|
967
|
+
}
|
968
|
+
else
|
969
|
+
{
|
970
|
+
if ((_U_UINT)actual > (_U_UINT)expected)
|
971
|
+
Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > (_U_UINT)delta);
|
972
|
+
else
|
973
|
+
Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > (_U_UINT)delta);
|
974
|
+
}
|
975
|
+
|
976
|
+
if (Unity.CurrentTestFailed)
|
977
|
+
{
|
978
|
+
UnityTestResultsFailBegin(lineNumber);
|
979
|
+
UnityPrint(UnityStrDelta);
|
980
|
+
UnityPrintNumberByStyle(delta, style);
|
981
|
+
UnityPrint(UnityStrExpected);
|
982
|
+
UnityPrintNumberByStyle(expected, style);
|
983
|
+
UnityPrint(UnityStrWas);
|
984
|
+
UnityPrintNumberByStyle(actual, style);
|
985
|
+
UnityAddMsgIfSpecified(msg);
|
986
|
+
UNITY_FAIL_AND_BAIL;
|
987
|
+
}
|
988
|
+
}
|
989
|
+
|
990
|
+
//-----------------------------------------------
|
991
|
+
void UnityAssertEqualString(const char* expected,
|
992
|
+
const char* actual,
|
993
|
+
const char* msg,
|
994
|
+
const UNITY_LINE_TYPE lineNumber)
|
995
|
+
{
|
996
|
+
_UU32 i;
|
997
|
+
|
998
|
+
UNITY_SKIP_EXECUTION;
|
999
|
+
|
1000
|
+
// if both pointers not null compare the strings
|
1001
|
+
if (expected && actual)
|
1002
|
+
{
|
1003
|
+
for (i = 0; expected[i] || actual[i]; i++)
|
1004
|
+
{
|
1005
|
+
if (expected[i] != actual[i])
|
1006
|
+
{
|
1007
|
+
Unity.CurrentTestFailed = 1;
|
1008
|
+
break;
|
1009
|
+
}
|
1010
|
+
}
|
1011
|
+
}
|
1012
|
+
else
|
1013
|
+
{ // handle case of one pointers being null (if both null, test should pass)
|
1014
|
+
if (expected != actual)
|
1015
|
+
{
|
1016
|
+
Unity.CurrentTestFailed = 1;
|
1017
|
+
}
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
if (Unity.CurrentTestFailed)
|
1021
|
+
{
|
1022
|
+
UnityTestResultsFailBegin(lineNumber);
|
1023
|
+
UnityPrintExpectedAndActualStrings(expected, actual);
|
1024
|
+
UnityAddMsgIfSpecified(msg);
|
1025
|
+
UNITY_FAIL_AND_BAIL;
|
1026
|
+
}
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
//-----------------------------------------------
|
1030
|
+
void UnityAssertEqualStringLen(const char* expected,
|
1031
|
+
const char* actual,
|
1032
|
+
const _UU32 length,
|
1033
|
+
const char* msg,
|
1034
|
+
const UNITY_LINE_TYPE lineNumber)
|
1035
|
+
{
|
1036
|
+
_UU32 i;
|
1037
|
+
|
1038
|
+
UNITY_SKIP_EXECUTION;
|
1039
|
+
|
1040
|
+
// if both pointers not null compare the strings
|
1041
|
+
if (expected && actual)
|
1042
|
+
{
|
1043
|
+
for (i = 0; (expected[i] || actual[i]) && i < length; i++)
|
1044
|
+
{
|
1045
|
+
if (expected[i] != actual[i])
|
1046
|
+
{
|
1047
|
+
Unity.CurrentTestFailed = 1;
|
1048
|
+
break;
|
1049
|
+
}
|
1050
|
+
}
|
1051
|
+
}
|
1052
|
+
else
|
1053
|
+
{ // handle case of one pointers being null (if both null, test should pass)
|
1054
|
+
if (expected != actual)
|
1055
|
+
{
|
1056
|
+
Unity.CurrentTestFailed = 1;
|
1057
|
+
}
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
if (Unity.CurrentTestFailed)
|
1061
|
+
{
|
1062
|
+
UnityTestResultsFailBegin(lineNumber);
|
1063
|
+
UnityPrintExpectedAndActualStringsLen(expected, actual, length);
|
1064
|
+
UnityAddMsgIfSpecified(msg);
|
1065
|
+
UNITY_FAIL_AND_BAIL;
|
1066
|
+
}
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
|
1070
|
+
//-----------------------------------------------
|
1071
|
+
void UnityAssertEqualStringArray( const char** expected,
|
1072
|
+
const char** actual,
|
1073
|
+
const _UU32 num_elements,
|
1074
|
+
const char* msg,
|
1075
|
+
const UNITY_LINE_TYPE lineNumber)
|
1076
|
+
{
|
1077
|
+
_UU32 i, j = 0;
|
1078
|
+
|
1079
|
+
UNITY_SKIP_EXECUTION;
|
1080
|
+
|
1081
|
+
// if no elements, it's an error
|
1082
|
+
if (num_elements == 0)
|
1083
|
+
{
|
1084
|
+
UnityTestResultsFailBegin(lineNumber);
|
1085
|
+
UnityPrint(UnityStrPointless);
|
1086
|
+
UnityAddMsgIfSpecified(msg);
|
1087
|
+
UNITY_FAIL_AND_BAIL;
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
|
1091
|
+
return;
|
1092
|
+
|
1093
|
+
do
|
1094
|
+
{
|
1095
|
+
// if both pointers not null compare the strings
|
1096
|
+
if (expected[j] && actual[j])
|
1097
|
+
{
|
1098
|
+
for (i = 0; expected[j][i] || actual[j][i]; i++)
|
1099
|
+
{
|
1100
|
+
if (expected[j][i] != actual[j][i])
|
1101
|
+
{
|
1102
|
+
Unity.CurrentTestFailed = 1;
|
1103
|
+
break;
|
1104
|
+
}
|
1105
|
+
}
|
1106
|
+
}
|
1107
|
+
else
|
1108
|
+
{ // handle case of one pointers being null (if both null, test should pass)
|
1109
|
+
if (expected[j] != actual[j])
|
1110
|
+
{
|
1111
|
+
Unity.CurrentTestFailed = 1;
|
1112
|
+
}
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
if (Unity.CurrentTestFailed)
|
1116
|
+
{
|
1117
|
+
UnityTestResultsFailBegin(lineNumber);
|
1118
|
+
if (num_elements > 1)
|
1119
|
+
{
|
1120
|
+
UnityPrint(UnityStrElement);
|
1121
|
+
UnityPrintNumberByStyle((j), UNITY_DISPLAY_STYLE_UINT);
|
1122
|
+
}
|
1123
|
+
UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
|
1124
|
+
UnityAddMsgIfSpecified(msg);
|
1125
|
+
UNITY_FAIL_AND_BAIL;
|
1126
|
+
}
|
1127
|
+
} while (++j < num_elements);
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
//-----------------------------------------------
|
1131
|
+
void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected,
|
1132
|
+
UNITY_PTR_ATTRIBUTE const void* actual,
|
1133
|
+
const _UU32 length,
|
1134
|
+
const _UU32 num_elements,
|
1135
|
+
const char* msg,
|
1136
|
+
const UNITY_LINE_TYPE lineNumber)
|
1137
|
+
{
|
1138
|
+
UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
|
1139
|
+
UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
|
1140
|
+
_UU32 elements = num_elements;
|
1141
|
+
_UU32 bytes;
|
1142
|
+
|
1143
|
+
UNITY_SKIP_EXECUTION;
|
1144
|
+
|
1145
|
+
if ((elements == 0) || (length == 0))
|
1146
|
+
{
|
1147
|
+
UnityTestResultsFailBegin(lineNumber);
|
1148
|
+
UnityPrint(UnityStrPointless);
|
1149
|
+
UnityAddMsgIfSpecified(msg);
|
1150
|
+
UNITY_FAIL_AND_BAIL;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE const void*)expected, (UNITY_PTR_ATTRIBUTE const void*)actual, lineNumber, msg) == 1)
|
1154
|
+
return;
|
1155
|
+
|
1156
|
+
while (elements--)
|
1157
|
+
{
|
1158
|
+
/////////////////////////////////////
|
1159
|
+
bytes = length;
|
1160
|
+
while (bytes--)
|
1161
|
+
{
|
1162
|
+
if (*ptr_exp != *ptr_act)
|
1163
|
+
{
|
1164
|
+
UnityTestResultsFailBegin(lineNumber);
|
1165
|
+
UnityPrint(UnityStrMemory);
|
1166
|
+
if (num_elements > 1)
|
1167
|
+
{
|
1168
|
+
UnityPrint(UnityStrElement);
|
1169
|
+
UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
|
1170
|
+
}
|
1171
|
+
UnityPrint(UnityStrByte);
|
1172
|
+
UnityPrintNumberByStyle((length - bytes - 1), UNITY_DISPLAY_STYLE_UINT);
|
1173
|
+
UnityPrint(UnityStrExpected);
|
1174
|
+
UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
|
1175
|
+
UnityPrint(UnityStrWas);
|
1176
|
+
UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
|
1177
|
+
UnityAddMsgIfSpecified(msg);
|
1178
|
+
UNITY_FAIL_AND_BAIL;
|
1179
|
+
}
|
1180
|
+
ptr_exp = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_exp + 1);
|
1181
|
+
ptr_act = (UNITY_PTR_ATTRIBUTE const void*)((_UP)ptr_act + 1);
|
1182
|
+
}
|
1183
|
+
/////////////////////////////////////
|
1184
|
+
|
1185
|
+
}
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
//-----------------------------------------------
|
1189
|
+
// Control Functions
|
1190
|
+
//-----------------------------------------------
|
1191
|
+
|
1192
|
+
void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
|
1193
|
+
{
|
1194
|
+
UNITY_SKIP_EXECUTION;
|
1195
|
+
|
1196
|
+
UnityTestResultsBegin(Unity.TestFile, line);
|
1197
|
+
UnityPrintFail();
|
1198
|
+
if (msg != NULL)
|
1199
|
+
{
|
1200
|
+
UNITY_OUTPUT_CHAR(':');
|
1201
|
+
if (msg[0] != ' ')
|
1202
|
+
{
|
1203
|
+
UNITY_OUTPUT_CHAR(' ');
|
1204
|
+
}
|
1205
|
+
UnityPrint(msg);
|
1206
|
+
}
|
1207
|
+
UNITY_FAIL_AND_BAIL;
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
//-----------------------------------------------
|
1211
|
+
void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
|
1212
|
+
{
|
1213
|
+
UNITY_SKIP_EXECUTION;
|
1214
|
+
|
1215
|
+
UnityTestResultsBegin(Unity.TestFile, line);
|
1216
|
+
UnityPrint(UnityStrIgnore);
|
1217
|
+
if (msg != NULL)
|
1218
|
+
{
|
1219
|
+
UNITY_OUTPUT_CHAR(':');
|
1220
|
+
UNITY_OUTPUT_CHAR(' ');
|
1221
|
+
UnityPrint(msg);
|
1222
|
+
}
|
1223
|
+
UNITY_IGNORE_AND_BAIL;
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
//-----------------------------------------------
|
1227
|
+
#if defined(UNITY_WEAK_ATTRIBUTE)
|
1228
|
+
void setUp(void);
|
1229
|
+
void tearDown(void);
|
1230
|
+
UNITY_WEAK_ATTRIBUTE void setUp(void) { }
|
1231
|
+
UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
|
1232
|
+
#elif defined(UNITY_WEAK_PRAGMA)
|
1233
|
+
# pragma weak setUp
|
1234
|
+
void setUp(void);
|
1235
|
+
# pragma weak tearDown
|
1236
|
+
void tearDown(void);
|
1237
|
+
#else
|
1238
|
+
void setUp(void);
|
1239
|
+
void tearDown(void);
|
1240
|
+
#endif
|
1241
|
+
//-----------------------------------------------
|
1242
|
+
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
|
1243
|
+
{
|
1244
|
+
Unity.CurrentTestName = FuncName;
|
1245
|
+
Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
|
1246
|
+
Unity.NumberOfTests++;
|
1247
|
+
if (TEST_PROTECT())
|
1248
|
+
{
|
1249
|
+
setUp();
|
1250
|
+
Func();
|
1251
|
+
}
|
1252
|
+
if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
|
1253
|
+
{
|
1254
|
+
tearDown();
|
1255
|
+
}
|
1256
|
+
UnityConcludeTest();
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
//-----------------------------------------------
|
1260
|
+
void UnityBegin(const char* filename)
|
1261
|
+
{
|
1262
|
+
Unity.TestFile = filename;
|
1263
|
+
Unity.CurrentTestName = NULL;
|
1264
|
+
Unity.CurrentTestLineNumber = 0;
|
1265
|
+
Unity.NumberOfTests = 0;
|
1266
|
+
Unity.TestFailures = 0;
|
1267
|
+
Unity.TestIgnores = 0;
|
1268
|
+
Unity.CurrentTestFailed = 0;
|
1269
|
+
Unity.CurrentTestIgnored = 0;
|
1270
|
+
|
1271
|
+
UNITY_OUTPUT_START();
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
//-----------------------------------------------
|
1275
|
+
int UnityEnd(void)
|
1276
|
+
{
|
1277
|
+
UNITY_PRINT_EOL;
|
1278
|
+
UnityPrint(UnityStrBreaker);
|
1279
|
+
UNITY_PRINT_EOL;
|
1280
|
+
UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
|
1281
|
+
UnityPrint(UnityStrResultsTests);
|
1282
|
+
UnityPrintNumber((_U_SINT)(Unity.TestFailures));
|
1283
|
+
UnityPrint(UnityStrResultsFailures);
|
1284
|
+
UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
|
1285
|
+
UnityPrint(UnityStrResultsIgnored);
|
1286
|
+
UNITY_PRINT_EOL;
|
1287
|
+
if (Unity.TestFailures == 0U)
|
1288
|
+
{
|
1289
|
+
UnityPrintOk();
|
1290
|
+
}
|
1291
|
+
else
|
1292
|
+
{
|
1293
|
+
UnityPrintFail();
|
1294
|
+
}
|
1295
|
+
UNITY_PRINT_EOL;
|
1296
|
+
UNITY_OUTPUT_COMPLETE();
|
1297
|
+
return (int)(Unity.TestFailures);
|
1298
|
+
}
|
1299
|
+
|
1300
|
+
//-----------------------------------------------
|