Commit 1ab95438 authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Fixed Table's = operator concatenating instead of overwritting. Fixes #1743

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6712 41f8697f-d340-4b68-9986-7bafba869bb8
parent 9ac8e624
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ namespace Isis {
   * @return @b Table The copied table.
   */
  Table &Table::operator=(const Isis::Table &other) {
    Clear();
    *((Isis::Blob *)this) = *((Isis::Blob *)&other);
    p_record = other.p_record;
    p_records = other.p_records;
+4 −1
Original line number Diff line number Diff line
@@ -24,7 +24,10 @@ Number of Fields Before Delete = 4
Number of Records After Delete = 1
Number of Fields  After Delete = 4

Testing operator= method...
Testing operator= method with empty table...
-1	0.5	HI	-0.55	

Testing operator= method with non empty table...
-1	0.5	HI	-0.55	

Testing Clear  method...
+20 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ int main(int argc, char *argv[]) {

    // use operator=
    Table t4 = t3;
    cout << "Testing operator= method..." << endl;
    cout << "Testing operator= method with empty table..." << endl;
    for (int i = 0; i < t4.Records(); i++) {
      for (int j = 0; j < t4.RecordFields(); j++) {
        if (j == 0) {
@@ -125,6 +125,25 @@ int main(int argc, char *argv[]) {
    }
    cout << endl;
    
    Table t5 = t2;
    t5 = t4;
    cout << "Testing operator= method with non empty table..." << endl;
    for (int i = 0; i < t5.Records(); i++) {
      for (int j = 0; j < t5.RecordFields(); j++) {
        if (j == 0) {
          cout << (int) t5[i][j] << "\t";
        }
        else if (j == 1 || j == 3) {
          cout << (double) t5[i][j] << "\t";
        }
        else if (j == 2) {
          cout << QString(t5[i][j]) << "\t";
        }
      }
      cout << endl;
    }
    cout << endl;

    cout << "Testing Clear  method..." << endl;
    t4.Clear();
    cout << "Number of Records = " << t4.Records() << endl;