[ next ] [ prev ] [ contents ] [ skip to Untying the Knot ] XP-Cinti TDD Workshop

Testing in a Matrix

So, what test will force us to use a Matrix? Referencing a position other than (1,1) should do it.

# file: testnet.rb
...
  def test_multiple_positions
    net = Net.new
    net.tie(1,1)
    assert_equal false, net.untied?(1,1)
    assert_equal true, net.untied?(1,2)
    assert_equal true, net.untied?(2,1)
    assert_equal true, net.untied?(2,2)
  end
...

And running the test gives us ...

  
$ ruby testnet.rb
Loaded suite testnet
Started...
..
Failure occurred in test_multiple_positions(TestNet) [testnet.rb:21]: Expected <true> but was <false>
..
Finished in 0.07461 seconds.
3 runs, 4 assertions, 1 failures, 0 errors

We are not surprised by this outcome. We expected it to fail because we are using only a single boolean in our Net object.


[ next ] [ prev ] [ contents ] [ skip to Untying the Knot ] Copyright 2003 by Jim Weirich.
Some Rights Reserved