[glom/glom-1-20] test_selfhosting_new_then_change_columns: Add a column too.



commit 2ef9a5f5e09610ae3ec9faad7dd7ce379174c7c3
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Dec 5 14:19:08 2011 +0100

    test_selfhosting_new_then_change_columns: Add a column too.
    
    * tests/test_selfhosting_new_then_change_columns.cc:

 ChangeLog                                         |    6 ++++
 tests/test_selfhosting_new_then_change_columns.cc |   29 +++++++++++++++++++++
 tests/test_selfhosting_new_then_choices.cc        |    3 +-
 3 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 73c4e2e..08d1945 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-12-05  Murray Cumming  <murrayc murrayc com>
 
+	test_selfhosting_new_then_change_columns: Add a column too.
+
+	* tests/test_selfhosting_new_then_change_columns.cc:
+
+2011-12-05  Murray Cumming  <murrayc murrayc com>
+
 	Added a test of field choices.
 
 	* Makefile_tests.am: 
diff --git a/tests/test_selfhosting_new_then_change_columns.cc b/tests/test_selfhosting_new_then_change_columns.cc
index 357f205..e333ed2 100644
--- a/tests/test_selfhosting_new_then_change_columns.cc
+++ b/tests/test_selfhosting_new_then_change_columns.cc
@@ -117,6 +117,35 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     std::cerr << "Failure: change_column() threw an exception: " << ex.what() << std::endl;
     return false;
   }
+  
+  //Add a field:
+  try
+  {
+    //TODO: Avoid the need for this awkward use of set_g_type():
+    Glom::sharedptr<Glom::Field> field = Glom::sharedptr<Glom::Field>::create();
+    field->set_name("newfield");
+    field->set_glom_type(Glom::Field::TYPE_NUMERIC);
+    Glib::RefPtr<Gnome::Gda::Column> field_info = field->get_field_info();
+    field_info->set_g_type( Glom::Field::get_gda_type_for_glom_type(field->get_glom_type()) );
+    field->set_field_info(field_info);
+    
+    Gnome::Gda::Numeric numeric;
+    numeric.set_double(123);
+    field->set_default_value( Gnome::Gda::Value(numeric) );
+
+    const bool test = connection_pool->add_column(table_name, field);
+    if(!test)
+    {
+      std::cerr << "Failure: add_column() failed." << std::endl;
+      return false;
+    }
+  }
+  catch(const Glib::Error& ex)
+  { 
+    std::cerr << "Failure: add_column() threw an exception: " << ex.what() << std::endl;
+    return false;
+  }
+  
 
   //Anything using this code would then update the Glom::Document,
   //for instance by calling Document::set_table_fields(),
diff --git a/tests/test_selfhosting_new_then_choices.cc b/tests/test_selfhosting_new_then_choices.cc
index 0e2cc71..906c9ee 100644
--- a/tests/test_selfhosting_new_then_choices.cc
+++ b/tests/test_selfhosting_new_then_choices.cc
@@ -61,7 +61,8 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     return false;
   }
   
-  const std::pair<Gnome::Gda::Value, Glom::Utils::type_list_values> pair_values = *(values_with_second.begin());
+  const std::pair<Gnome::Gda::Value, Glom::Utils::type_list_values> pair_values 
+    = *(values_with_second.begin());
   if(pair_values.second.size() != 1)
   {
     std::cerr << "Failure: There were an unexpected number of field values in each choice." << std::endl;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]