[glom] tests: Avoid some more shadowed variables.



commit d44045fefa57890ce068bdfe14bbece70ad18522
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jul 6 20:09:39 2015 +0200

    tests: Avoid some more shadowed variables.

 glom/test_pyembed.cc                              |   19 ++++++-----
 tests/test_selfhosting_new_then_change_columns.cc |   36 ++++++++++----------
 2 files changed, 28 insertions(+), 27 deletions(-)
---
diff --git a/glom/test_pyembed.cc b/glom/test_pyembed.cc
index cf960c6..23a4eab 100644
--- a/glom/test_pyembed.cc
+++ b/glom/test_pyembed.cc
@@ -52,25 +52,25 @@ void evaluate_function_implementation(const Glib::ustring& func_impl)
   PyObject* pDict = PyModule_GetDict(pMain);
 
   //Create the function definition:
-  PyObject* pyValue = PyRun_String(func_def.c_str(), Py_file_input, pDict, pDict);
-  if(pyValue)
+  PyObject* pyValueFunc = PyRun_String(func_def.c_str(), Py_file_input, pDict, pDict);
+  if(pyValueFunc)
   {
-    Py_DECREF(pyValue);
-    pyValue = nullptr;
+    Py_DECREF(pyValueFunc);
+    pyValueFunc = nullptr;
   }
 
   //Call the function:
   {
     Glib::ustring call_func = "glom_calc_field_value()";
-    PyObject* pyValue = PyRun_String(call_func.c_str(), Py_eval_input, pDict, pDict);
-    if(!pyValue)
+    PyObject* pyValueCall = PyRun_String(call_func.c_str(), Py_eval_input, pDict, pDict);
+    if(!pyValueCall)
     {
-      g_warning("pyValue was null");
+      g_warning("pyValueCall was null");
       PyErr_Print();
     }
     else
     {
-      PyObject* pyStringObject = PyObject_Str(pyValue);
+      PyObject* pyStringObject = PyObject_Str(pyValueCall);
       if(pyStringObject)
       {
         if(PyUnicode_Check(pyStringObject))
@@ -91,7 +91,8 @@ void evaluate_function_implementation(const Glib::ustring& func_impl)
       else
         g_warning("pyStringObject is null");
 
-      Py_DECREF(pyValue);
+      Py_DECREF(pyValueCall);
+      pyValueCall = nullptr;
     }
   }
 
diff --git a/tests/test_selfhosting_new_then_change_columns.cc 
b/tests/test_selfhosting_new_then_change_columns.cc
index 3c3f8f1..4a61865 100644
--- a/tests/test_selfhosting_new_then_change_columns.cc
+++ b/tests/test_selfhosting_new_then_change_columns.cc
@@ -45,14 +45,14 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   
   const Glib::ustring table_name = "contacts";
   const Glib::ustring field_name_original = "date_of_birth";
-  std::shared_ptr<const Glom::Field> field = document.get_field(table_name, field_name_original);
-  if(!field)
+  std::shared_ptr<const Glom::Field> field_original = document.get_field(table_name, field_name_original);
+  if(!field_original)
   {
     std::cerr << G_STRFUNC << ": Failure: Could not get field." << std::endl;
     return false;
   }
 
-  std::shared_ptr<Glom::Field> field_new = Glom::glom_sharedptr_clone(field);
+  std::shared_ptr<Glom::Field> field_new = Glom::glom_sharedptr_clone(field_original);
   if(!field_new)
   {
     std::cerr << G_STRFUNC << ": Failure: field_new is null." << std::endl;
@@ -72,7 +72,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   //and check that the result is as expected:
   try
   {
-    const auto test = connection_pool->change_column(table_name, field, field_new);
+    const auto test = connection_pool->change_column(table_name, field_original, field_new);
     if(!test)
     {
       std::cerr << G_STRFUNC << ": Failure: change_column() failed." << std::endl;
@@ -86,11 +86,11 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
 
   //Try another change:
-  field = Glom::glom_sharedptr_clone(field_new);
+  field_original = Glom::glom_sharedptr_clone(field_new);
   field_new->set_glom_type(Glom::Field::TYPE_NUMERIC);
   try
   {
-    const auto test = connection_pool->change_column(table_name, field, field_new);
+    const auto test = connection_pool->change_column(table_name, field_original, field_new);
     if(!test)
     {
       std::cerr << G_STRFUNC << ": Failure: change_column() failed." << std::endl;
@@ -104,11 +104,11 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
 
   //Try another change:
-  field = Glom::glom_sharedptr_clone(field_new);
+  field_original = Glom::glom_sharedptr_clone(field_new);
   field_new->set_name("somenewfieldname");
   try
   {
-    const auto test = connection_pool->change_column(table_name, field, field_new);
+    const auto test = connection_pool->change_column(table_name, field_original, field_new);
     if(!test)
     {
       std::cerr << G_STRFUNC << ": Failure: change_column() failed." << std::endl;
@@ -122,11 +122,11 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
 
   //Try to make it auto-increment:
-  field = Glom::glom_sharedptr_clone(field_new);
+  field_original = Glom::glom_sharedptr_clone(field_new);
   field_new->set_auto_increment();
   try
   {
-    const auto test = connection_pool->change_column(table_name, field, field_new);
+    const auto test = connection_pool->change_column(table_name, field_original, field_new);
     if(!test)
     {
       std::cerr << G_STRFUNC << ": Failure: change_column() failed." << std::endl;
@@ -156,18 +156,18 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   try
   {
     //TODO: Avoid the need for this awkward use of set_g_type():
-    std::shared_ptr<Glom::Field> field = std::make_shared<Glom::Field>();
-    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);
+    std::shared_ptr<Glom::Field> field_numeric = std::make_shared<Glom::Field>();
+    field_numeric->set_name("newfield");
+    field_numeric->set_glom_type(Glom::Field::TYPE_NUMERIC);
+    Glib::RefPtr<Gnome::Gda::Column> field_info = field_numeric->get_field_info();
+    field_info->set_g_type( Glom::Field::get_gda_type_for_glom_type(field_numeric->get_glom_type()) );
+    field_numeric->set_field_info(field_info);
     
     Gnome::Gda::Numeric numeric;
     numeric.set_double(123);
-    field->set_default_value( Gnome::Gda::Value(numeric) );
+    field_numeric->set_default_value( Gnome::Gda::Value(numeric) );
 
-    const auto test = connection_pool->add_column(table_name, field);
+    const auto test = connection_pool->add_column(table_name, field_numeric);
     if(!test)
     {
       std::cerr << G_STRFUNC << ": Failure: add_column() failed." << std::endl;


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