Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Commit

Permalink
Added Chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
kfazi committed Jan 29, 2016
1 parent 6dafbc1 commit 7a63012
Show file tree
Hide file tree
Showing 12 changed files with 1,304 additions and 10 deletions.
18 changes: 17 additions & 1 deletion Numsense.UnitTests.CSharp/NumeralConverterProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,23 @@ public static Arbitrary<ConverterPropertyGroup> Converter()
new ConverterPropertyGroup(
new RussianNumeralConverter(),
NumeralModule.toRussian,
NumeralModule.tryParseRussian)
NumeralModule.tryParseRussian),
new ConverterPropertyGroup(
new TraditionalChineseNumeralConverter(),
NumeralModule.toTraditionalChinese,
NumeralModule.tryParseTraditionalChinese),
new ConverterPropertyGroup(
new TraditionalFinancialChineseNumeralConverter(),
NumeralModule.toTraditionalFinancialChinese,
NumeralModule.tryParseTraditionalFinancialChinese),
new ConverterPropertyGroup(
new SimplifiedChineseNumeralConverter(),
NumeralModule.toSimplifiedChinese,
NumeralModule.tryParseSimplifiedChinese),
new ConverterPropertyGroup(
new SimplifiedFinancialChineseNumeralConverter(),
NumeralModule.toSimplifiedFinancialChinese,
NumeralModule.tryParseSimplifiedFinancialChinese)
)
.ToArbitrary();
}
Expand Down
64 changes: 63 additions & 1 deletion Numsense.UnitTests.CSharp/NumeralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,68 @@ public void RussianIsSingleton()
var expected = Numeral.Russian;
var actual = Numeral.Russian;
Assert.Same(expected, actual);
}
}

[Fact]
public void TraditionalChineseIsCorrect()
{
var actual = Numeral.TraditionalChinese;
Assert.IsAssignableFrom<TraditionalChineseNumeralConverter>(actual);
}

[Fact]
public void TraditionalChineseIsSingleton()
{
var expected = Numeral.TraditionalChinese;
var actual = Numeral.TraditionalChinese;
Assert.Same(expected, actual);
}

[Fact]
public void TraditionalFinancialChineseIsCorrect()
{
var actual = Numeral.TraditionalFinancialChinese;
Assert.IsAssignableFrom
<TraditionalFinancialChineseNumeralConverter>(actual);
}

[Fact]
public void TraditionalFinancialChineseIsSingleton()
{
var expected = Numeral.TraditionalFinancialChinese;
var actual = Numeral.TraditionalFinancialChinese;
Assert.Same(expected, actual);
}

[Fact]
public void SimplifiedChineseIsCorrect()
{
var actual = Numeral.SimplifiedChinese;
Assert.IsAssignableFrom<SimplifiedChineseNumeralConverter>(actual);
}

[Fact]
public void SimplifiedChineseIsSingleton()
{
var expected = Numeral.SimplifiedChinese;
var actual = Numeral.SimplifiedChinese;
Assert.Same(expected, actual);
}

[Fact]
public void SimplifiedFinancialChineseIsCorrect()
{
var actual = Numeral.SimplifiedFinancialChinese;
Assert.IsAssignableFrom
<SimplifiedFinancialChineseNumeralConverter>(actual);
}

[Fact]
public void SimplifiedFinancialChineseIsSingleton()
{
var expected = Numeral.SimplifiedFinancialChinese;
var actual = Numeral.SimplifiedFinancialChinese;
Assert.Same(expected, actual);
}
}
}
64 changes: 64 additions & 0 deletions Numsense.UnitTests/NumeralProperties.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,68 @@ let ``negative Russian is the inverse of positive Russian`` x =
let actualInteger = Numeral.tryParseRussian actualRussian

sprintf "минус %s" (Numeral.toRussian x) =! actualRussian
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseTraditionalChinese is the inverse of toTraditionalChinese`` x =
test <@ Some x = (x |> Numeral.toTraditionalChinese
|> Numeral.tryParseTraditionalChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative TraditionalChinese is the inverse of positive TraditionalChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toTraditionalChinese -x
let actualInteger = Numeral.tryParseTraditionalChinese actualChinese

sprintf "%s" (Numeral.toTraditionalChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseTraditionalFinancialChinese is the inverse of toTraditionalFinancialChinese`` x =
test <@ Some x = (x |> Numeral.toTraditionalFinancialChinese
|> Numeral.tryParseTraditionalFinancialChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative TraditionalFinancialChinese is the inverse of positive TraditionalFinancialChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toTraditionalFinancialChinese -x
let actualInteger = Numeral.tryParseTraditionalFinancialChinese actualChinese

sprintf "%s" (Numeral.toTraditionalFinancialChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseSimplifiedChinese is the inverse of toSimplifiedChinese`` x =
test <@ Some x = (x |> Numeral.toSimplifiedChinese
|> Numeral.tryParseSimplifiedChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative SimplifiedChinese is the inverse of positive SimplifiedChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toSimplifiedChinese -x
let actualInteger = Numeral.tryParseSimplifiedChinese actualChinese

sprintf "%s" (Numeral.toSimplifiedChinese x) =! actualChinese
Some -x =! actualInteger

[<Property(QuietOnSuccess = true)>]
let ``tryParseSimplifiedFinancialChinese is the inverse of toSimplifiedFinancialChinese`` x =
test <@ Some x = (x |> Numeral.toSimplifiedFinancialChinese
|> Numeral.tryParseSimplifiedFinancialChinese) @>

[<Property(QuietOnSuccess = true)>]
let ``negative SimplifiedFinancialChinese is the inverse of positive SimplifiedFinancialChinese`` x =
x <> 0 ==> lazy
let x = abs x

let actualChinese = Numeral.toSimplifiedFinancialChinese -x
let actualInteger = Numeral.tryParseSimplifiedFinancialChinese actualChinese

sprintf "%s" (Numeral.toSimplifiedFinancialChinese x) =! actualChinese
Some -x =! actualInteger
6 changes: 5 additions & 1 deletion Numsense.UnitTests/Numsense.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@
<Compile Include="EnglishExamples.fs" />
<Compile Include="PolishExamples.fs" />
<Compile Include="DutchExamples.fs" />
<Compile Include="RussianExamples.fs" />
<Compile Include="RussianExamples.fs" />
<Compile Include="TraditionalChineseExamples.fs" />
<Compile Include="TraditionalFinancialChineseExamples.fs" />
<Compile Include="SimplifiedChineseExamples.fs" />
<Compile Include="SimplifiedFinancialChineseExamples.fs" />
<Compile Include="Demo.fs" />
<Content Include="packages.config" />
<Content Include="App.config" />
Expand Down
Loading

0 comments on commit 7a63012

Please sign in to comment.