Sha256: 9dd9fef17ac5b23dd281086365f453f7a049bcc91744f4d4495d26488dd1ec0c

Contents?: true

Size: 1.77 KB

Versions: 72

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( input='1' ) ).toBeFalse();
			});

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

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

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

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

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

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

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

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

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

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

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

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

		});
		
	}
 
}

Version data entries

72 entries across 71 versions & 1 rubygems

Version Path
trackler-2.2.1.104 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.103 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.102 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.101 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.100 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.99 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.98 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.97 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.96 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.95 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.94 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.93 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.92 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.91 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.90 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.89 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.88 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.87 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.86 tracks/cfml/exercises/luhn/LuhnTest.cfc
trackler-2.2.1.85 tracks/cfml/exercises/luhn/LuhnTest.cfc