Add unit test for parameterized strings.
This commit is contained in:
parent
8e453c1995
commit
d87e00307a
3 changed files with 22 additions and 0 deletions
5
test/fixtures/strings-3.txt
vendored
Normal file
5
test/fixtures/strings-3.txt
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
[[My Strings]]
|
||||
[parameterized_string]
|
||||
en = The %@ brown fox jumps over the %@ dog %d times.
|
||||
[percentage_string]
|
||||
en = This product is %d%% off.
|
9
test/fixtures/test-output-8.txt
vendored
Normal file
9
test/fixtures/test-output-8.txt
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Android Strings File -->
|
||||
<!-- Generated by Twine <%= Twine::VERSION %> -->
|
||||
<!-- Language: en -->
|
||||
<resources>
|
||||
<!-- SECTION: My Strings -->
|
||||
<string name="parameterized_string">The %1$s brown fox jumps over the %2$s dog %3$d times.</string>
|
||||
<string name="percentage_string">This product is %d%% off.</string>
|
||||
</resources>
|
|
@ -44,6 +44,14 @@ class TwineTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_generate_string_file_6
|
||||
Dir.mktmpdir do |dir|
|
||||
output_path = File.join(dir, 'en.xml')
|
||||
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-3.txt #{output_path}))
|
||||
assert_equal(ERB.new(File.read('test/fixtures/test-output-8.txt')).result, File.read(output_path))
|
||||
end
|
||||
end
|
||||
|
||||
def test_consume_string_file_1
|
||||
Dir.mktmpdir do |dir|
|
||||
output_path = File.join(dir, 'strings.txt')
|
||||
|
|
Reference in a new issue