Skip to content

Instantly share code, notes, and snippets.

View HectorTorres's full-sized avatar

Hector Torres HectorTorres

View GitHub Profile
<?php
// test/Unit/UserTest.php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class Password {
protected $password = "";
// tests.cpp
#include "whattotest.cpp"
#include <gtest/gtest.h>
TEST(SquareRootTest, PositiveNos) {
ASSERT_EQ(6, squareRoot(36.0));
ASSERT_EQ(18.0, squareRoot(324.0));
ASSERT_EQ(25.4, squareRoot(645.16));
ASSERT_EQ(0, squareRoot(0.0));
}
// whattotest.cpp
#include <math.h>
double squareRoot(const double a) {
double b = sqrt(a);
if(b != b) { // nan check
return -1.0;
}else{
return sqrt(a);
}
# Se requiere definir una version minima de cmake, por compatibilidad
cmake_minimum_required(VERSION 3.22)
# Se requiere definir un nombre de proyecto.
project("Gtest")
# Buscar el paquete GTest
find_package(GTest REQUIRED)
# Vincular el archivo de salida con el de pruebas
add_executable(a.out test.cpp)
import math
def function_rectangle_type(a,b,c):
if (a == b) and (b == c):
return "Equilatero"
elif (a != b) and (b != c):
return "Escaleno"
else:
return "Isoceles"
#include <iostream>
using namespace std;
int main() {
double n1, n2, n3;
cout << "Enter three numbers, enter or space between numbers: ";
cin >> n1 >> n2 >> n3;
import math
def function_square(a):
return a*a
def function_square_root(a):
return math.sqrt(a)
def function_sum(a,b):
return a+b
import unittest
import math
def function_square(a):
return a*a
def function_square_root(a):
return math.sqrt(a)
def function_sum(a,b):
import unittest
def function_square(a):
return a*a
class Test(unittest.TestCase):
def test_function_square(self):
self.assertEquals(function_square(2),4)
#run the program
def function_square(a):
return a*a
def test_function_square():
assert function_square(2) == 5
test_function_square()
#Run the file
#pytest test_pytest_01.py