Skip to content

Instantly share code, notes, and snippets.

Avatar

Hector Torres HectorTorres

View GitHub Profile
View UserTest.php
<?php
// test/Unit/UserTest.php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class Password {
protected $password = "";
View tests.cpp
// 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));
}
View whattotest.cpp
// 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);
}
View CMakeLists.txt
# 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)
View test_pytest_a09.py
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"
View max_number.cpp
#include <iostream>
using namespace std;
int main() {
double n1, n2, n3;
cout << "Enter three numbers, enter or space between numbers: ";
cin >> n1 >> n2 >> n3;
View test_pytest_02.py
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
View test_unit_02.py
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):
View test_unit_01.py
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
View test_pytest_01.py
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