Sha256: ee9c8ccfbcce74fcacf753715049533b7dadb927707ed07e6870af7675c7451f

Contents?: true

Size: 1.77 KB

Versions: 74

Compression:

Stored size: 1.77 KB

Contents

component extends="testbox.system.BaseSpec" {

	function beforeAll(){
	  SUT = createObject( 'Luhn' );
	}

	function run(){
	
		describe( "My Luhn class", function(){			

			it( 'single digit strings can not be valid', function(){
				expect( SUT.valid( value='1' ) ).toBeFalse();
			});

			it( 'a single zero is invalid', function(){
				expect( SUT.valid( value='0' ) ).toBeFalse();
			});

			it( 'a simple valid SIN that remains valid if reversed', function(){
				expect( SUT.valid( value='059' ) ).toBeTrue();
			});

			it( 'a simple valid SIN that becomes invalid if reversed', function(){
				expect( SUT.valid( value='59' ) ).toBeTrue();
			});

			it( 'a valid Canadian SIN', function(){
				expect( SUT.valid( value='055 444 285' ) ).toBeTrue();
			});

			it( 'invalid Canadian SIN', function(){
				expect( SUT.valid( value='055 444 286' ) ).toBeFalse();
			});

			it( 'invalid credit card', function(){
				expect( SUT.valid( value='8273 1232 7352 0569' ) ).toBeFalse();
			});

			it( 'valid strings with a non-digit included become invalid', function(){
				expect( SUT.valid( value='055a 444 285' ) ).toBeFalse();
			});

			it( 'valid strings with punctuation included become invalid', function(){
				expect( SUT.valid( value='055-444-285' ) ).toBeFalse();
			});

			it( 'valid strings with symbols included become invalid', function(){
				expect( SUT.valid( value='055£ 444$ 285' ) ).toBeFalse();
			});

			it( 'single zero with space is invalid', function(){
				expect( SUT.valid( value=' 0' ) ).toBeFalse();
			});

			it( 'more than a single zero is valid', function(){
				expect( SUT.valid( value='0000 0' ) ).toBeTrue();
			});

			it( 'input digit 9 is correctly converted to output digit 9', function(){
				expect( SUT.valid( value='091' ) ).toBeTrue();
			});

		});
		
	}
 
}

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.179 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.178 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.177 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.176 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.175 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.174 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.173 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.172 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.171 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.170 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.169 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.167 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.166 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.165 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.164 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.163 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.162 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.161 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.160 tracks/cfml/exercises/luhn/LuhnTest.cfc