Commits

Palmer, 2E0EOL committed 75af8e3

Apply part of DirScan testbed to Verifier

  • Participants
  • Parent commits 9df0f7a
  • Branches f/201112-palmer-ut

Comments (0)

Files changed (1)

File t/Verifier.t

 use warnings;
 use diagnostics;
 
-use Test::More tests => (1);
+use Test::More tests => (4);
 require 'dlverifycd';
 #----------------------------------------------------------------------------
+sub test_e2d3e3cb
+{
+	my @methods = (
+		'Seek',
+		'Scan',
+		'Clear'
+	);
+
+	my ( $TestName, $O ) = @_;
+	foreach my $m ( @methods ) {
+		can_ok($O, $m);
+	}
+}
+#----------------------------------------------------------------------------
 sub TestMain()
 {
-	my $o = Verifier->new();
-	isa_ok($o, 'Verifier', 'new');
+	# The test list, defines the order the tests are run in.
+	my @tests = (
+		'e2d3e3cb-80fb-4d26-a57e-b81dd25c51e3'
+	);
+	my %testFuncs = (
+		'e2d3e3cb-80fb-4d26-a57e-b81dd25c51e3' => {
+			'N' => 'Public methods',
+			'C' => \&test_e2d3e3cb
+		}
+	);
+
+	my $o = DirScan->new();
+	isa_ok($o, 'DirScan', 'new');
+	foreach my $uuid ( @tests ) {
+		my $testRef = $testFuncs{$uuid};
+		if ( $testRef ) {
+			my $type = ref($testRef);
+			if ( $type && $type eq 'HASH' ) {
+				my $codeInvoked = FALSE();
+				my ( $testName, $testCode ) = ( $testRef->{'N'}, $testRef->{'C'} );
+				die(sprintf('Test {%s} has no name', $uuid)) if ( !$testName || length($testName) == 0 );
+				if ( $testCode ) {
+					my $testCodeType = ref($testCode);
+					if ( $testCodeType && $testCodeType eq 'CODE' ) {
+						$testCode->($testName, $o);
+						$codeInvoked = TRUE();
+					}
+				}
+				die(sprintf('Test {%s} defined no code', $uuid)) if ( !$codeInvoked );
+			} else {
+				die(sprintf('Test {%s} is not of type \'HASH\'', $uuid));
+			}
+		} else {
+			die(sprintf('Test {%s} in list, not defined in detail', $uuid));
+		}
+	}
 	return 0;
 }
 #----------------------------------------------------------------------------