コード例 #1
0
///-----------------------------------------------------------------------------
TEST_F(OpcUaBinaryDeserialization, Variant_LOCALIZED_TEXT)
{
  using namespace OpcUa;
  using namespace OpcUa::Binary;

  char encodingMask = static_cast<char>(VariantType::LOCALIZED_TEXT);

  const std::vector<char> expectedData =
  {
    encodingMask,
    2, 4, 0, 0, 0, 't', 'e', 'x', 't'
  };

  GetChannel().SetData(expectedData);

  Variant var;
  GetStream() >> var;

  ASSERT_EQ(var.Type(), VariantType::LOCALIZED_TEXT);
  ASSERT_EQ(var.As<LocalizedText>(), LocalizedText("text"));
  ASSERT_FALSE(var.IsNul());
  ASSERT_FALSE(var.IsArray());
  ASSERT_TRUE(var.Dimensions.empty());
}
コード例 #2
0
///-----------------------------------------------------------------------------
TEST_F(OpcUaBinaryDeserialization, Variant_BYTE_STRING)
{
  using namespace OpcUa;
  using namespace OpcUa::Binary;

  char encodingMask = static_cast<char>(VariantType::BYTE_STRING);

  const std::vector<char> expectedData =
  {
    encodingMask,
    2, 0, 0, 0, 1, 2
  };

  GetChannel().SetData(expectedData);

  Variant var;
  GetStream() >> var;

  ASSERT_EQ(var.Type(), VariantType::BYTE_STRING);
  ASSERT_EQ(var.As<ByteString>(), ByteString(std::vector<uint8_t> {1, 2}));
  ASSERT_FALSE(var.IsNul());
  ASSERT_FALSE(var.IsArray());
  ASSERT_TRUE(var.Dimensions.empty());
}
コード例 #3
0
///-----------------------------------------------------------------------------
TEST_F(OpcUaBinaryDeserialization, Variant_DATETIME)
{
  using namespace OpcUa;
  using namespace OpcUa::Binary;

  char encodingMask = static_cast<char>(VariantType::DATE_TIME);

  const std::vector<char> expectedData =
  {
    encodingMask,
    8, 7, 6, 5, 4, 3, 2, 1
  };

  GetChannel().SetData(expectedData);

  Variant var;
  GetStream() >> var;

  ASSERT_EQ(var.Type(), VariantType::DATE_TIME);
  ASSERT_EQ(var.As<DateTime>(), 0x0102030405060708);
  ASSERT_FALSE(var.IsNul());
  ASSERT_FALSE(var.IsArray());
  ASSERT_TRUE(var.Dimensions.empty());
}
コード例 #4
0
///-----------------------------------------------------------------------------
TEST_F(OpcUaBinaryDeserialization, Variant_STRING)
{
  using namespace OpcUa;
  using namespace OpcUa::Binary;

  char encodingMask = static_cast<char>(VariantType::STRING);

  const std::vector<char> expectedData =
  {
    encodingMask,
    4, 0, 0, 0, 'R', 'o', 'o', 't'
  };

  GetChannel().SetData(expectedData);

  Variant var;
  GetStream() >> var;

  ASSERT_EQ(var.Type(), VariantType::STRING);
  ASSERT_EQ(var.As<std::string>(), std::string("Root"));
  ASSERT_FALSE(var.IsNul());
  ASSERT_FALSE(var.IsArray());
  ASSERT_TRUE(var.Dimensions.empty());
}