Skip to content
Snippets Groups Projects
Select Git revision
  • dev
  • main default protected
  • f-unmod
  • f-checkidentical
  • f-simple-breakpoint
  • f-new-debug-tree
  • f-existing-file-id
  • f-no-ident
  • f-collect-problems
  • f-refactor-debug-tree
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.1
  • v0.10.0
  • v0.9.1
  • v0.9.0
  • v0.8.0
  • v0.7.1
  • v0.7.0
  • v0.6.0
  • v0.5.0
  • v0.4.0
  • v0.3.0
  • v0.2.0
  • v0.1.0
26 results

concept.md

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_value.cpp 5.91 KiB
    /*
     *
     * This file is a part of the CaosDB Project.
     *
     * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
     * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as
     * published by the Free Software Foundation, either version 3 of the
     * License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public License
     * along with this program. If not, see <https://www.gnu.org/licenses/>.
     *
     */
    
    #include "caosdb/value.h"             // for Value
    #include "caosdb/entity/v1/main.pb.h" // for AtomicDataType, DataType
    #include "caosdb/protobuf_helper.h"   // for ProtoMessageWrapper
    #include <algorithm>                  // for max
    #include <cmath>                      // for isnan
    #include <gtest/gtest-message.h>      // for Message
    #include <gtest/gtest-test-part.h>    // for TestPartResult, SuiteApi...
    #include <gtest/gtest_pred_impl.h>    // for AssertionResult, Test
    #include <initializer_list>           // for initializer_list
    #include <string>                     // for string, basic_string
    #include <vector>                     // for vector
    
    namespace caosdb::entity {
    using ProtoValue = caosdb::entity::v1::Value;
    using ProtoEntity = caosdb::entity::v1::Entity;
    using ProtoParent = caosdb::entity::v1::Parent;
    using ProtoDataType = caosdb::entity::v1::DataType;
    using ProtoAtomicDataType = caosdb::entity::v1::AtomicDataType;
    
    TEST(test_value, test_null) {
      Value value;
      EXPECT_TRUE(value.IsNull());
      EXPECT_FALSE(value.IsDouble());
      EXPECT_FALSE(value.IsBool());
      EXPECT_FALSE(value.IsInt64());
      EXPECT_FALSE(value.IsString());
      EXPECT_FALSE(value.IsVector());
    }
    
    TEST(test_value, test_string) {
      Value value(std::string("test"));
      EXPECT_FALSE(value.IsNull());
      EXPECT_TRUE(value.IsString());
      EXPECT_FALSE(value.IsDouble());
      EXPECT_FALSE(value.IsBool());
      EXPECT_FALSE(value.IsInt64());
    
      EXPECT_EQ(value.GetAsString(), "test");
    
      Value empty_string(std::string(""));
      EXPECT_FALSE(empty_string.IsNull());
      EXPECT_TRUE(empty_string.IsString());
      EXPECT_FALSE(empty_string.IsDouble());
      EXPECT_FALSE(empty_string.IsBool());
      EXPECT_FALSE(empty_string.IsInt64());
    
      EXPECT_EQ(empty_string.GetAsString(), "");