src/core/value-test.cc
changeset 2384 500ada6a4874
parent 2381 816df299095d
child 2385 ae4d6740d5a0
equal deleted inserted replaced
2383:a0e0ec096169 2384:500ada6a4874
     3 #include "object.h"
     3 #include "object.h"
     4 #include "boolean-value.h"
     4 #include "boolean-value.h"
     5 #include "int-value.h"
     5 #include "int-value.h"
     6 #include "uint-value.h"
     6 #include "uint-value.h"
     7 #include "enum-value.h"
     7 #include "enum-value.h"
       
     8 #include "random-variable.h"
     8 #if 0
     9 #if 0
     9 #include "fp-value.h"
    10 #include "fp-value.h"
    10 #endif
    11 #endif
    11 namespace ns3 {
    12 namespace ns3 {
    12 
    13 
    64       .AddParameter ("TestEnum", "help text",
    65       .AddParameter ("TestEnum", "help text",
    65 		     MakeEnumParamSpec (&ParamSpecObjectTest::m_enum,
    66 		     MakeEnumParamSpec (&ParamSpecObjectTest::m_enum,
    66 					TEST_A, "TestA",
    67 					TEST_A, "TestA",
    67 					TEST_B, "TestB",
    68 					TEST_B, "TestB",
    68 					TEST_C, "TestC"))
    69 					TEST_C, "TestC"))
       
    70       .AddParameter ("TestRandom", "help text",
       
    71 		     MakeRandomVariableParamSpec (&ParamSpecObjectTest::m_random,
       
    72 						  ConstantVariable (1.0)))
    69 #if 0
    73 #if 0
    70       .AddParameter ("TestFloat", "help text",
    74       .AddParameter ("TestFloat", "help text",
    71 		     MakeFpParamSpec (-1.1, &ParamSpecObjectTest::m_float))
    75 		     MakeFpParamSpec (-1.1, &ParamSpecObjectTest::m_float))
    72 #endif
    76 #endif
    73       ;
    77       ;
    95   int16_t m_int16WithBounds;
    99   int16_t m_int16WithBounds;
    96   int16_t m_int16SetGet;
   100   int16_t m_int16SetGet;
    97   uint8_t m_uint8;
   101   uint8_t m_uint8;
    98   float m_float;
   102   float m_float;
    99   enum TestEnum m_enum;
   103   enum TestEnum m_enum;
       
   104   RandomVariable m_random;
   100 };
   105 };
   101 
   106 
   102 
   107 
   103 #define CHECK_GET_STR(p,name,value)		\
   108 #define CHECK_GET_STR(p,name,value)		\
   104   {						\
   109   {						\
   263   CHECK_GET_PARAM (p, "TestEnum", EnumValue, ParamSpecObjectTest::TEST_B);
   268   CHECK_GET_PARAM (p, "TestEnum", EnumValue, ParamSpecObjectTest::TEST_B);
   264   NS_TEST_ASSERT (!p->Set ("TestEnum", EnumValue (5)));
   269   NS_TEST_ASSERT (!p->Set ("TestEnum", EnumValue (5)));
   265   CHECK_GET_STR (p, "TestEnum", "TestB");
   270   CHECK_GET_STR (p, "TestEnum", "TestB");
   266   CHECK_GET_PARAM (p, "TestEnum", EnumValue, ParamSpecObjectTest::TEST_B);
   271   CHECK_GET_PARAM (p, "TestEnum", EnumValue, ParamSpecObjectTest::TEST_B);
   267 
   272 
       
   273   RandomVariable ran = p->Get ("TestRandom");
       
   274   NS_TEST_ASSERT (p->Set ("TestRandom", UniformVariable (0.0, 1.0)));
       
   275   NS_TEST_ASSERT (p->Set ("TestRandom", ConstantVariable (10.0)));
       
   276   
       
   277 
   268 #if 0
   278 #if 0
   269   p->Set ("TestBoolName", "true");
   279   p->Set ("TestBoolName", "true");
   270   NS_TEST_ASSERT_EQUAL (p->Get ("TestBoolName"), "true");
   280   NS_TEST_ASSERT_EQUAL (p->Get ("TestBoolName"), "true");
   271   p->Set ("TestBoolName", "false");
   281   p->Set ("TestBoolName", "false");
   272   NS_TEST_ASSERT_EQUAL (p->Get ("TestBoolName"), "false");
   282   NS_TEST_ASSERT_EQUAL (p->Get ("TestBoolName"), "false");