Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements Made #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions test/test.cpp
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
#include <cstdio>

#include "test.h"

// Forward declarations for test suites
CuSuite* TestP2GetSuite();
CuSuite* TestP3GetSuite();
CuSuite* TestIeeeGetSuite();

void genSubTable(POSIT_STYPE *sub_table, POSIT_STYPE *add_table, int size)
{
for (int i = 0; i < size; i++) {
int k;
// Function to generate subtraction table from addition table
void genSubTable(POSIT_STYPE *sub_table, const POSIT_STYPE *add_table, int size) {
for (int i = 0; i < size; ++i) {
int adjustedIndex;

if (i == 0) {
k = 0;
adjustedIndex = 0;
} else {
k = size / 2 - (i - size / 2);
adjustedIndex = size / 2 - (i - size / 2);
}

for (int j = 0; j < size; j++) {
sub_table[k * size + j] = add_table[i * size + j];
for (int j = 0; j < size; ++j) {
sub_table[adjustedIndex * size + j] = add_table[i * size + j];
}
}
}

void genDivTable(POSIT_STYPE *div_table, POSIT_STYPE *mul_table, int size)
{
for (int i = 0; i < size; i++) {
int k;
// Function to generate division table from multiplication table
void genDivTable(POSIT_STYPE *div_table, const POSIT_STYPE *mul_table, int size) {
for (int i = 0; i < size; ++i) {
int adjustedIndex;

if (i <= size / 2) {
k = size / 2 - i;
adjustedIndex = size / 2 - i;
} else {
k = size - (i - size / 2);
adjustedIndex = size - (i - size / 2);
}

for (int j = 0; j < size; j++) {
if (k == size / 2) {
// TODO explain
div_table[k * size + j] = mul_table[size / 2 * size + j];
for (int j = 0; j < size; ++j) {
// Special case handling for the central index
if (adjustedIndex == size / 2) {
div_table[adjustedIndex * size + j] = mul_table[(size / 2) * size + j];
} else {
div_table[k * size + j] = mul_table[i * size + j];
div_table[adjustedIndex * size + j] = mul_table[i * size + j];
}
}
}
}

void RunAllTests(void)
{
// Function to run all test suites and print the results
void RunAllTests() {
CuString *output = CuStringNew();
CuSuite *suite = CuSuiteNew();

Expand All @@ -58,9 +58,14 @@ void RunAllTests(void)
CuSuiteSummary(suite, output);
CuSuiteDetails(suite, output);
printf("%s", output->buffer);

// Clean up
CuStringDelete(output);
CuSuiteDelete(suite);
}

int main(int argc, char *argv[])
{
// Main function to start the test execution
int main(int argc, char *argv[]) {
RunAllTests();
return 0;
}