ct_common  1.0.1
Common library for combinatorial testing
src/ct_common/common/test_case.cpp
Go to the documentation of this file.
00001 //===----- ct_common/common/test_case.cpp -----------------------*- C++ -*-===//
00002 //
00003 //                      The ct_common Library
00004 //
00005 // This file is distributed under the MIT license. See LICENSE for details.
00006 //
00007 //===----------------------------------------------------------------------===//
00008 //
00009 // This file contains the function definitions of class TestCase
00010 //
00011 //===----------------------------------------------------------------------===//
00012 
00013 #include <ct_common/common/defs.h>
00014 #include <ct_common/common/test_case.h>
00015 
00016 using namespace ct::common;
00017 
00018 TestCase::TestCase(void)
00019   : Assignment(), std::vector<std::size_t>() {
00020 }
00021 
00022 TestCase::TestCase(const TestCase &from)
00023   : Assignment(from), std::vector<std::size_t>() {
00024 }
00025 
00026 TestCase::~TestCase(void) {
00027 }
00028 
00029 TestCase &TestCase::operator =(const TestCase &right) {
00030   Assignment::operator =(right);
00031   std::vector<std::size_t>::operator =(right);
00032   return *this;
00033 }
00034 
00035 bool TestCase::IsContainParam(std::size_t pid) const {
00036   return pid < this->size();
00037 }
00038 
00039 std::size_t TestCase::GetValue(std::size_t pid) const {
00040   if (this->IsContainParam(pid)) {
00041     return (*this)[pid];
00042   }
00043   return PID_BOUND;
00044 }
00045 
00046 bool TestCase::IsSubAssignmentOf(const Assignment &assignment) const {
00047   for (std::size_t i = 0; i < this->size(); ++i) {
00048     if (!assignment.IsContainParam(i) || assignment.GetValue(i) != (*this)[i]) {
00049       return false;
00050     }
00051   }
00052   return true;
00053 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines