M6 KVM avatar M6 KVM committed 2256ba2

Add the unit tests from the dlcdverifer project

Comments (0)

Files changed (1)

+#!/usr/bin/perl -w
+#
+# This unit test uses Test::More and tests the DirScan component of the script.
+#
+
+package main;
+use strict;
+use warnings;
+use diagnostics;
+
+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()
+{
+	# 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;
+}
+#----------------------------------------------------------------------------
+exit(TestMain());
+#----------------------------------------------------------------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.