Code Search for Developers
 
 
  

FitMatcherTest.java from MASE: Agile Software Engineering at Krugle


Show FitMatcherTest.java syntax highlighted

// Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
// Copyright (c) 2002 Cunningham & Cunningham, Inc.
// Released under the terms of the GNU General Public License version 2 or later.
package fit;

import junit.framework.TestCase;

public class FitMatcherTest extends TestCase
{
  private void assertMatch(String expression, Number parameter) throws Exception
  {
    FitMatcher matcher = new FitMatcher(expression, parameter);
    assertTrue(matcher.matches());
  }

  private void assertNoMatch(String expression, Number parameter) throws Exception
  {
    FitMatcher matcher = new FitMatcher(expression, parameter);
    assertFalse(matcher.matches());
  }

  private void assertException(String expression, Object parameter)
  {
    FitMatcher matcher = new FitMatcher(expression, parameter);
    try
    {
      matcher.matches();
      fail();
    }
    catch(Exception e)
    {
    }
  }

  public void testSimpleMatches() throws Exception
  {
    assertMatch("_<3", new Integer(2));
    assertNoMatch("_<3", new Integer(3));
    assertMatch("_<4", new Integer(3));
    assertMatch("_ < 9", new Integer(4));
    assertMatch("<3", new Integer(2));
    assertMatch(">4", new Integer(5));
    assertMatch(">-3", new Integer(-2));
    assertMatch("<3.2", new Double(3.1));
    assertNoMatch("<3.2", new Double(3.3));
    assertMatch("<=3", new Double(3));
    assertMatch("<=3", new Double(2));
    assertNoMatch("<=3", new Double(4));
    assertMatch(">=2", new Double(2));
    assertMatch(">=2", new Double(3));
    assertNoMatch(">=2", new Double(1));
  }

  public void testExceptions() throws Exception
  {
    assertException("X", new Integer(1));
    assertException("<32", "xxx");
  }

  public void testMessage() throws Exception
  {
    FitMatcher matcher = new FitMatcher("_>25", new Integer(3));
    assertEquals("<b>3</b>>25", matcher.message());
    matcher = new FitMatcher(" < 32", new Integer(5));
    assertEquals("<b>5</b> < 32", matcher.message());
  }

  public void testTrichotomy() throws Exception
  {
    assertMatch("5<_<32", new Integer(8));
    assertNoMatch("5<_<32", new Integer(5));
    assertNoMatch("5<_<32", new Integer(32));
    assertMatch("10>_>5", new Integer(6));
    assertNoMatch("10>_>5", new Integer(10));
    assertNoMatch("10>_>5", new Integer(5));
    assertMatch("10>=_>=5", new Integer(10));
    assertMatch("10>=_>=5", new Integer(5));
  }

}




See more files for this project here

MASE: Agile Software Engineering

The MASE project investigates methods to support the coordination and executable acceptance testing of software projects. Keywords: Agile methods, distributed teams, Extreme Programming. See http://ebe.cpsc.ucalgary.ca/ebe for more information.

Project homepage: http://sourceforge.net/projects/mase
Programming language(s): Java,XML
License: other

  exception/
    AmbiguousActionException.java
    AmbiguousNameFailureException.java
    BooleanMethodFitFailureException.java
    ClassIsNotFixtureException.java
    CouldNotLoadComponentFitFailureException.java
    CouldNotParseFitFailureException.java
    CycleException.java
    ExtraCellsFailureException.java
    FitFailureException.java
    FitFailureExceptionWithHelp.java
    FitMatcherException.java
    FitParseException.java
    FixtureException.java
    IgnoredException.java
    MissingCellsFailureException.java
    MissingFieldFitFailureException.java
    MissingMethodException.java
    MissingRowFailureException.java
    NestedTableExpected.java
    NoDefaultConstructorFixtureException.java
    NoSuchFieldFitFailureException.java
    NoSuchFixtureException.java
    NoSuchMethodFitFailureException.java
    RowWrongWidthException.java
    VoidMethodFitFailureException.java
  ActionFixture.java
  Binding.java
  ColumnFixture.java
  ColumnFixtureTest.java
  Comment.java
  Counts.java
  CountsTest.java
  FileRunner.java
  FitMatcher.java
  FitMatcherTest.java
  Fixture.java
  FixtureClass.java
  FixtureListener.java
  FixtureLoader.java
  FixtureLoaderTest.java
  FixtureName.java
  GracefulNamer.java
  GracefulNamerTest.java
  ImportFixture.java
  NullFixtureListener.java
  Parse.java
  ParseTest.java
  PrimitiveFixture.java
  RowFixture.java
  RowFixtureTest.java
  ScientificDouble.java
  ScientificDoubleTest.java
  SummaryFixture.java
  TestRunner.java
  TimedActionFixture.java
  TypeAdapter.java
  TypeAdapterTest.java
  WikiRunner.java