[LON-CAPA-cvs] cvs: loncom /cfgedittests delete.t
foxr
lon-capa-cvs@mail.lon-capa.org
Tue, 02 Dec 2003 12:12:16 -0000
foxr Tue Dec 2 07:12:16 2003 EDT
Modified files:
/loncom/cfgedittests delete.t
Log:
1. Fix broken test for how lines move after delete.
2. Add tests to ensure that deleted lines are no longer really in the file.
Index: loncom/cfgedittests/delete.t
diff -u loncom/cfgedittests/delete.t:1.2 loncom/cfgedittests/delete.t:1.3
--- loncom/cfgedittests/delete.t:1.2 Tue Nov 25 07:15:35 2003
+++ loncom/cfgedittests/delete.t Tue Dec 2 07:12:16 2003
@@ -1,5 +1,5 @@
#
-# $Id: delete.t,v 1.2 2003/11/25 12:15:35 foxr Exp $
+# $Id: delete.t,v 1.3 2003/12/02 12:12:16 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,7 +43,7 @@
# from the middle.
#
-BEGIN {plan tests => 6}
+BEGIN {plan tests => 8}
#
# Test deletion of middle element.
@@ -57,13 +57,24 @@
my $editor = ConfigFileEdit->new("test2config.cfg", 0);
my $linecount = $editor->LineCount();
+ my $hashref = $editor->{KeyToLines};
+ my $initiallast = $hashref->{"last"};
+
$editor->DeleteLine("line2");
ok($editor->LineCount(), $linecount-1);
- my $hashref = $editor->{KeyToLines};
+ $hashref = $editor->{KeyToLines};
ok($hashref->{"line1"}, 0);
- ok($hashref->{"last"}, $editor->LineCount()-1);
+ ok($hashref->{"last"}, $initiallast-1);
+
+ my $deleted = $editor->Find("line2");
+ if(!defined($deleted)) {
+ ok(1);
+ } else {
+ ok(0);
+ }
+
}
#
@@ -86,6 +97,13 @@
$hashref = $editor->{KeyToLines}; # Hash may change due to reindex!!
ok($hashref->{"line1"}, $line1idx);
ok($hashref->{"line2"}, $line2idx);
+
+ my $deleted = $editor->Find("last");
+ if(!defined($deleted)) {
+ ok(1);
+ } else {
+ ok(0);
+ }
}