Ignore:
Timestamp:
May 28, 2013, 11:17:14 AM (11 years ago)
Author:
meunier
Message:

Tried to clean the test_regression directory:

  • Code formatting
  • Supressed warnings
  • Made comprehensible outputs
  • Factorized Makefiles

There's still a lot to do (many tests don't pass for either good or bad reasons)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/test_regression/28102005/system.cpp

    r35 r55  
    1 #include <systemc.h>
     1
    22#include <iostream>
    33#include <cstring>
    44
    5 #define ASSERT(x) \
    6   { errnum++; \
    7     if (!(x)) \
    8     { \
    9     cerr << "ASSERT : " #x "\n"; \
    10     exit (errnum); \
    11     } \
    12   }
    13 
    14 #ifdef DEBUG
    15 #define CERR(x) \
    16   { cerr << "" #x " = " << x << "\n"; }
    17 #else
    18 #define CERR(x)
    19 #endif
     5#include "systemc.h"
     6#include "test.h"
    207
    218
    229using namespace std;
    2310
    24 static int errnum = 0;
    2511
    26 void
    27 check_time (int i)
    28 {
    29   const sc_time &t = sc_time_stamp ();
    30   CERR(i);
    31   CERR(t.to_double());
     12void check_time(int i) {
     13    const sc_time & t = sc_time_stamp();
     14    cout << i << endl;
     15
    3216#ifdef SYSTEMCASS_SPECIFIC
    33   ASSERT((int) (t.to_double ()) == i);
     17    ASSERT((int) (t.to_double()) == i);
    3418#else
    35   ASSERT((int) (t.to_double ()) == i * 1000);
     19    ASSERT((int) (t.to_double()) == i * 1000);
    3620#endif
    37   CERR(t.to_seconds ());
    38         double seconds = t.to_seconds()*1000000000;
    39   CERR(seconds);
    40   ASSERT(((int)seconds) == i);
    41   char s[256];
    42   const char *unit;
     21
     22    cout << t.to_seconds() << endl;
     23    double seconds = t.to_seconds() * 1000000000;
     24    cout << seconds << endl;
     25    ASSERT(((int) seconds) == i);
     26    char s[256];
     27    const char * unit;
     28
    4329#ifdef SYSTEMCASS_SPECIFIC
    44   unit = "NS";
     30    unit = "NS";
    4531#else
    46   if (i == 0)
    47     unit = "s";
    48   else if (i < 1000)
    49     unit = "ns";
    50   else
    51     unit = "ns";
     32    if (i == 0) {
     33        unit = "s";
     34    }
     35    else {
     36        unit = "ns";
     37    }
    5238#endif
    53   sprintf (s, "%d %s", i,unit);
    54   CERR(s);
    55   CERR(t.to_string());
    56   ASSERT(strcmp (t.to_string ().c_str(), s)== 0);
     39
     40    sprintf(s, "%d %s", i, unit);
     41
     42    ASSERT(strcmp(t.to_string().c_str(), s) == 0);
    5743}
    5844
    59 int
    60 sc_main (int argc, char ** argv)
    61 {
    62   sc_clock clk ("clock");
    6345
    64   check_time (0);
    65   sc_start (0);
     46int sc_main (int argc, char ** argv) {
     47    sc_clock clk("clock");
    6648
    67   check_time (0);
    68   sc_start (1);
    69   check_time (1);
     49    check_time(0);
     50    sc_start(sc_time(0, sc_core::SC_NS));
    7051
    71   sc_start (15);
    72   check_time (16);
     52    check_time(0);
     53    sc_start(sc_time(1, sc_core::SC_NS));
     54    check_time(1);
    7355
    74   sc_start (7);
    75   check_time (23);
     56    sc_start(sc_time(15, sc_core::SC_NS));
     57    check_time(16);
    7658
    77   sc_start (100);
    78   check_time (123);
     59    sc_start(sc_time(7, sc_core::SC_NS));
     60    check_time(23);
    7961
    80   sc_start (1000);
    81   check_time (1123);
    82   cerr << "Test OK.\n";
    83   return 0;
     62    sc_start(sc_time(100, sc_core::SC_NS));
     63    check_time(123);
     64
     65    sc_start(sc_time(1000, sc_core::SC_NS));
     66    check_time(1123);
     67
     68    return 0;
    8469}
    8570
     71
     72/*
     73# Local Variables:
     74# tab-width: 4;
     75# c-basic-offset: 4;
     76# c-file-offsets:((innamespace . 0)(inline-open . 0));
     77# indent-tabs-mode: nil;
     78# End:
     79#
     80# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     81*/
     82
Note: See TracChangeset for help on using the changeset viewer.