Commit ca63ea7f authored by Pavel Vainerman's avatar Pavel Vainerman

(VTypes): исправлена ошибка в wsize для типов Signed и Unsigned

parent 3a902769
...@@ -35,7 +35,7 @@ namespace UniSetUDP ...@@ -35,7 +35,7 @@ namespace UniSetUDP
friend std::ostream& operator<<( std::ostream& os, UDPHeader* p ); friend std::ostream& operator<<( std::ostream& os, UDPHeader* p );
} __attribute__((packed)); } __attribute__((packed));
static unsigned long MaxPacketNum = std::numeric_limits<unsigned long>::max(); const unsigned long MaxPacketNum = std::numeric_limits<unsigned long>::max();
struct UDPAData struct UDPAData
{ {
......
...@@ -259,7 +259,7 @@ namespace VTypes ...@@ -259,7 +259,7 @@ namespace VTypes
/*! размер в словах */ /*! размер в словах */
static int wsize() static int wsize()
{ {
return sizeof(unsigned short); return 1;
} }
/*! тип значения */ /*! тип значения */
static VType type() static VType type()
...@@ -298,7 +298,7 @@ namespace VTypes ...@@ -298,7 +298,7 @@ namespace VTypes
/*! размер в словах */ /*! размер в словах */
static int wsize() static int wsize()
{ {
return sizeof(signed short); return 1;
} }
/*! тип значения */ /*! тип значения */
static VType type() static VType type()
......
...@@ -2,11 +2,25 @@ ...@@ -2,11 +2,25 @@
#include <limits> #include <limits>
#include "VTypes.h" #include "VTypes.h"
// -----------------------------------------------------------------------------
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace VTypes; using namespace VTypes;
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: wsize test", "[vtypes][wsize]")
{
REQUIRE( F2::wsize() == 2 );
REQUIRE( F2r::wsize() == 2 );
REQUIRE( F4::wsize() == 4 );
REQUIRE( Byte::wsize() == 1 );
REQUIRE( Unsigned::wsize() == 1 );
REQUIRE( Signed::wsize() == 1 );
REQUIRE( I2::wsize() == 2 );
REQUIRE( I2r::wsize() == 2 );
REQUIRE( U2::wsize() == 2 );
REQUIRE( U2r::wsize() == 2 );
}
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: I2", "[vtypes][I2]") TEST_CASE("VTypes: I2", "[vtypes][I2]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -33,7 +47,7 @@ TEST_CASE("VTypes: I2", "[vtypes][I2]") ...@@ -33,7 +47,7 @@ TEST_CASE("VTypes: I2", "[vtypes][I2]")
REQUIRE( (int)v2 == -65536 ); REQUIRE( (int)v2 == -65536 );
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: I2r", "[vtypes][I2r]") TEST_CASE("VTypes: I2r", "[vtypes][I2r]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -68,7 +82,7 @@ TEST_CASE("VTypes: I2r", "[vtypes][I2r]") ...@@ -68,7 +82,7 @@ TEST_CASE("VTypes: I2r", "[vtypes][I2r]")
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: U2", "[vtypes][U2]") TEST_CASE("VTypes: U2", "[vtypes][U2]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -101,7 +115,7 @@ TEST_CASE("VTypes: U2", "[vtypes][U2]") ...@@ -101,7 +115,7 @@ TEST_CASE("VTypes: U2", "[vtypes][U2]")
REQUIRE( (unsigned int)v2 == 0xffff0000 ); REQUIRE( (unsigned int)v2 == 0xffff0000 );
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: U2r", "[vtypes][U2r]") TEST_CASE("VTypes: U2r", "[vtypes][U2r]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -155,7 +169,7 @@ TEST_CASE("VTypes: F2", "[vtypes][F2]") ...@@ -155,7 +169,7 @@ TEST_CASE("VTypes: F2", "[vtypes][F2]")
REQUIRE( (float)v2 == f ); REQUIRE( (float)v2 == f );
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: F2r", "[vtypes][F2r]") TEST_CASE("VTypes: F2r", "[vtypes][F2r]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -187,7 +201,7 @@ TEST_CASE("VTypes: F2r", "[vtypes][F2r]") ...@@ -187,7 +201,7 @@ TEST_CASE("VTypes: F2r", "[vtypes][F2r]")
REQUIRE( (float)v2 == f ); REQUIRE( (float)v2 == f );
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: F4", "[vtypes][F4]") TEST_CASE("VTypes: F4", "[vtypes][F4]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -233,7 +247,7 @@ TEST_CASE("VTypes: F4", "[vtypes][F4]") ...@@ -233,7 +247,7 @@ TEST_CASE("VTypes: F4", "[vtypes][F4]")
} }
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: Byte", "[vtypes][byte]") TEST_CASE("VTypes: Byte", "[vtypes][byte]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -260,7 +274,7 @@ TEST_CASE("VTypes: Byte", "[vtypes][byte]") ...@@ -260,7 +274,7 @@ TEST_CASE("VTypes: Byte", "[vtypes][byte]")
REQUIRE( (unsigned char)v[0] == 255 ); REQUIRE( (unsigned char)v[0] == 255 );
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: Unsigned", "[vtypes][unsigned]") TEST_CASE("VTypes: Unsigned", "[vtypes][unsigned]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -281,7 +295,7 @@ TEST_CASE("VTypes: Unsigned", "[vtypes][unsigned]") ...@@ -281,7 +295,7 @@ TEST_CASE("VTypes: Unsigned", "[vtypes][unsigned]")
REQUIRE( (unsigned short)v == 65535 ); REQUIRE( (unsigned short)v == 65535 );
} }
} }
// -----------------------------------------------------------------------------
TEST_CASE("VTypes: Signed", "[vtypes][signed]") TEST_CASE("VTypes: Signed", "[vtypes][signed]")
{ {
SECTION("Default constructor") SECTION("Default constructor")
...@@ -302,3 +316,4 @@ TEST_CASE("VTypes: Signed", "[vtypes][signed]") ...@@ -302,3 +316,4 @@ TEST_CASE("VTypes: Signed", "[vtypes][signed]")
REQUIRE( (signed short)v == (signed short)d ); REQUIRE( (signed short)v == (signed short)d );
} }
} }
// -----------------------------------------------------------------------------
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment