Commits

Anonymous committed af122ae

[svn r79] Write Quote() test, though Quote() doesn't exist yet.
There are intential problems with the @output array for testing purposes,
which will need to be corrected after Quote() is written.

  • Participants
  • Parent commits dbe6ab2

Comments (0)

Files changed (1)

branches/daybobase-0.2.0/daybobase-test.pl

 sub test_Rows();
 sub test_GetNextRow();
 sub test_ValidateStatementHandle();
+sub test_Quote();
 #----------------------------------------------------------------------------
 sub NewMain()
 {
     'GetCredentials' => { 'C' => \&test_GetCredentials },
     'Rows' => { 'C' => \&test_Rows },
     'GetNextRow' => { 'C' => \&test_GetNextRow },
-    'ValidateStatementHandle' => { 'C' => \&test_ValidateStatementHandle }
+    'ValidateStatementHandle' => { 'C' => \&test_ValidateStatementHandle },
+    'Quote' => { 'C' => \&test_Quote }
   );
   foreach my $k ( keys(%tests) ) {
     $tests{$k}->{'R'} = 1;
   return $ret;
 }
 #----------------------------------------------------------------------------
+sub test_Quote()
+{
+  my $ret = 0;
+  my $dbh = DayboBase::Handle();
+  if ( $dbh ) {
+    my @inputs = (
+      "\'test\'",
+      'test',
+      "gRoWl\'bleh"
+    );
+    my @outputs = (
+      "test",
+      "\'test\'",
+      "growlbleh",
+    );
+
+    for ( my $i = 0; $i < scalar(@inputs); $i++ ) {
+      if ( $outputs[$i] ne $dbh->Quote($inputs[$i]) ) {
+        printf(
+          "Quote() mis-match, input %s, output %s\n",
+          $inputs[$i], $outputs[$i]
+        );
+        return $ret;
+      }
+    }
+    $ret = 1;
+  }
+  return $ret;
+}
+#----------------------------------------------------------------------------
 sub Main()
 {
   my $ret = EXIT_FAILURE();