Skip to content

Instantly share code, notes, and snippets.

@dimka11
Created October 4, 2017 19:34
Show Gist options
  • Save dimka11/e2fd6cde0a7181fafbae5c18481782b2 to your computer and use it in GitHub Desktop.
Save dimka11/e2fd6cde0a7181fafbae5c18481782b2 to your computer and use it in GitHub Desktop.
test modf
#include "stdafx.h"
#include "CppUnitTest.h"
#include <iostream>                   // для оператора cout
#include <cmath>                      // для функции modf
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace modfUnit
{
TEST_CLASS(UnitTest1)
{
public:
TEST_METHOD(modf_with_3_14)
{
double val = 3.14159265;
double fractpart;// дробная часть
double intpart; // целая часть
fractpart = modf(val, &intpart); // отделить дробную часть от целой
double epsilon = 1.0e-15;
double Testfractpart = 0.14159265;
double Testintpart = 3;
bool CheckIntPart;
bool CheckFractPart;
(fabs(intpart - Testintpart) < epsilon) ? CheckIntPart = true : CheckIntPart = false;
(fabs(fractpart - Testfractpart) < epsilon) ? CheckFractPart = true : CheckFractPart = false;
Assert::IsTrue(CheckIntPart & CheckFractPart, L"Its smt wrong");
// TODO: Your test code here
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment