Exemple #1
0
int main()
{
   basic_test();
   reference_test();
   iterator_test();
   const_test();

   return boost::report_errors();
}
Exemple #2
0
Fichier : 41.c Projet : shixv/test
int main(void)
{
	const int a = 10;//变量a不是在常量区开辟的内存,而是依然在栈区开辟的。
	                         //只不过给这块内存,加了一个只读的属性。
	int b = 20;
	const_test(&a);

	const_test2(&b);

	return 0;
}
Exemple #3
0
int main()
{
   json::value value;

   BOOST_TEST( value.type() == json::null_type );

   value = ciere::json::object()
      ("number" ,123)
      ("foo"    ,"bar")
      ("meaning", 42)
      ;

   BOOST_TEST( value.type() == json::object_type );


   BOOST_TEST(value["number"]  == 123);
   BOOST_TEST(value["foo"]     == "bar");
   BOOST_TEST(value["meaning"] == 42);

   value["number"] = 78.3;
   BOOST_TEST(value["number"]  == 78.3);

   value["foo"] = ciere::json::object()
      ( "color",  "black" )
      ( "size" ,  93      )
      ( "tone" ,  ciere::json::null_t() )
      ;

   BOOST_TEST(value["foo"]["size"] == 93);
   BOOST_TEST(value["foo"]["color"] == "black");

   value["foo"]["color"] = "blue";
   BOOST_TEST(value["foo"]["color"] != "black");
   BOOST_TEST(value["foo"]["color"] == "blue");

   BOOST_TEST(value["foo"].length() == 3);

   json::value::object_iterator iter     = value["foo"].begin_object();
   json::value::object_iterator iter_end = value["foo"].end_object();
   BOOST_TEST( iter->name()  == "color" );
   BOOST_TEST( iter->value() == "blue" );
   ++iter;
   BOOST_TEST( iter->name()  == "size" );
   BOOST_TEST( iter->value() == 93 );
   ++iter;
   BOOST_TEST( iter->name()  == "tone" );
   BOOST_TEST( iter->value() == json::null_t() );
   ++iter;
   BOOST_TEST( iter == iter_end );

   value.set("bar", json::array()(42)("top")(1234.5) );
   BOOST_TEST( value.has_key("bar") );
   BOOST_TEST( !value.has_key("cafe") );
   BOOST_TEST( value["bar"][2] == 1234.5 );

   value.set("cafe", "open");
   BOOST_TEST(value["cafe"] == "open" );

   const_test(value);

   return boost::report_errors();
}
Exemple #4
0
void const_test()
{
   json::value v = json::array()(0)(1)(2)(3)(4);
   const_test(v);
}