Skip to content

Commit

Permalink
adding test case for fractions
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed Mar 7, 2011
1 parent c935f9d commit f15d146
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/mesh/core/number/FractionTests.as
@@ -0,0 +1,28 @@
package mesh.core.number
{
import mesh.core.object.inspect;

import org.flexunit.assertThat;
import org.hamcrest.object.equalTo;

public class FractionTests
{
[Test]
public function testGCD():void
{
var tests:Array = [
{a:1, b:2, expected:1},
{a:0, b:3, expected:3},
{a:3, b:0, expected:3},
{a:108, b:30, expected:6},
{a:-108, b:30, expected:6},
{a:108, b:-30, expected:6},
{a:-108, b:-30, expected:6}
];

for each (var test:Object in tests) {
assertThat("test failed: " + inspect(test), Fraction.gcd(test.a, test.b), equalTo(test.expected));
}
}
}
}

0 comments on commit f15d146

Please sign in to comment.