ct_common
1.0.1
Common library for combinatorial testing
|
00001 //===----- ct_common/common/exp_a_mod.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 Exp_A_Mod 00010 // 00011 //===----------------------------------------------------------------------===// 00012 00013 #include <ct_common/common/exp_a_mod.h> 00014 00015 using namespace ct::common; 00016 00017 Exp_A_Mod::Exp_A_Mod(void) 00018 : Exp_A_Binary() { 00019 } 00020 00021 Exp_A_Mod::Exp_A_Mod(const Exp_A_Mod &from) 00022 : Exp_A_Binary(from) { 00023 } 00024 00025 Exp_A_Mod& Exp_A_Mod::operator = (const Exp_A_Mod &right) { 00026 Exp_A_Binary::operator=(right); 00027 return *this; 00028 } 00029 00030 Exp_A_Mod::~Exp_A_Mod(void) { 00031 } 00032 00033 std::string Exp_A_Mod::get_class_name(void) const { 00034 return Exp_A_Mod::class_name(); 00035 } 00036 00037 std::string Exp_A_Mod::class_name(void) { 00038 return "Exp_A_Mod"; 00039 } 00040 00041 int Exp_A_Mod::evaluate_int(int val_1, int val_2) const { 00042 if (val_2 == 0) { 00043 CT_EXCEPTION("can not take the mod of zero"); 00044 } 00045 return val_1 % val_2; 00046 } 00047 00048 double Exp_A_Mod::evaluate_double(double val_1, double val_2) const { 00049 CT_EXCEPTION("both the two operands of % must be integer"); 00050 return (int)val_1 % (int)val_2; 00051 } 00052 00053 std::string Exp_A_Mod::get_op_token(void) const { 00054 return "%"; 00055 }