Skip to content

Commit

Permalink
fix(Tests): Fixed tests compilation on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
macmade committed Nov 12, 2024
1 parent 3423111 commit 6c8c0c6
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 121 deletions.
134 changes: 67 additions & 67 deletions SRPXX-Tests/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,191 +30,191 @@ XSTest( Client, SetB )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setB( constants.B() );
XSTestAssertTrue( client.B() == constants.B() );
client->setB( constants.B() );
XSTestAssertTrue( client->B() == constants.B() );
}
}

XSTest( Client, v )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
XSTestAssertTrue( client.v() == constants.v() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
XSTestAssertTrue( client->v() == constants.v() );
}
}

XSTest( Client, a )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

XSTestAssertTrue( client.a() == constants.a() );
XSTestAssertTrue( client->a() == constants.a() );
}
}

XSTest( Client, A )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

XSTestAssertTrue( client.A() == constants.A() );
XSTestAssertTrue( client->A() == constants.A() );
}
}

XSTest( Client, u )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
client.setB( constants.B() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
client->setB( constants.B() );

XSTestAssertTrue( client.u() == constants.u() );
XSTestAssertTrue( client->u() == constants.u() );
}
}

XSTest( Client, k )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
client.setB( constants.B() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
client->setB( constants.B() );

XSTestAssertTrue( client.k() == constants.k() );
XSTestAssertTrue( client->k() == constants.k() );
}
}

XSTest( Client, S )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
client.setB( constants.B() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
client->setB( constants.B() );

XSTestAssertTrue( client.S() == constants.S() );
XSTestAssertTrue( client->S() == constants.S() );
}
}

XSTest( Client, X )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
XSTestAssertTrue( client.x() == constants.x() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
XSTestAssertTrue( client->x() == constants.x() );
}
}

XSTest( Client, K )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
client.setB( constants.B() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
client->setB( constants.B() );

XSTestAssertTrue( client.K() == constants.K() );
XSTestAssertTrue( client->K() == constants.K() );
}
}

XSTest( Client, M1 )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
client.setB( constants.B() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
client->setB( constants.B() );

XSTestAssertTrue( client.M1() == constants.M1() );
XSTestAssertTrue( client->M1() == constants.M1() );
}
}

XSTest( Client, M2 )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

client.setPassword( constants.password() );
client.setSalt( constants.salt() );
client.setB( constants.B() );
client->setPassword( constants.password() );
client->setSalt( constants.salt() );
client->setB( constants.B() );

XSTestAssertTrue( client.M2() == constants.M2() );
XSTestAssertTrue( client->M2() == constants.M2() );
}
}

XSTest( Client, SetOptions )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.setOptions( static_cast< uint64_t >( SRP::Client::Options::NoUsernameInX ) );
XSTestAssertTrue( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.setOptions( 0 );
XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->setOptions( static_cast< uint64_t >( SRP::Client::Options::NoUsernameInX ) );
XSTestAssertTrue( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->setOptions( 0 );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
}
}

XSTest( Client, AddOption )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.addOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertTrue( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->addOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertTrue( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
}
}

XSTest( Client, RemoveOption )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.addOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertTrue( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.removeOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->addOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertTrue( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->removeOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
}
}

XSTest( Client, HasOption )
{
for( const auto & constants: Constants::all() )
{
SRP::Client client = constants.makeClient();
auto client = constants.makeClient();

XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.addOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertTrue( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
client.removeOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertFalse( client.hasOption( SRP::Client::Options::NoUsernameInX ) );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->addOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertTrue( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
client->removeOption( SRP::Client::Options::NoUsernameInX );
XSTestAssertFalse( client->hasOption( SRP::Client::Options::NoUsernameInX ) );
}
}
8 changes: 4 additions & 4 deletions SRPXX-Tests/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ void swap( Constants & o1, Constants & o2 )
swap( o1.impl, o2.impl );
}

SRP::Client Constants::makeClient() const
std::unique_ptr< SRP::Client > Constants::makeClient() const
{
return SRP::Client( this->identity(), this->impl->_hashAlgorithm, this->impl->_groupType, this->a() );
return std::make_unique< SRP::Client >( this->identity(), this->impl->_hashAlgorithm, this->impl->_groupType, this->a() );
}

SRP::Server Constants::makeServer() const
std::unique_ptr< SRP::Server > Constants::makeServer() const
{
return SRP::Server( this->identity(), this->impl->_hashAlgorithm, this->impl->_groupType, this->b() );
return std::make_unique< SRP::Server >( this->identity(), this->impl->_hashAlgorithm, this->impl->_groupType, this->b() );
}

SRP::HashAlgorithm Constants::hashAlgorithm() const
Expand Down
5 changes: 3 additions & 2 deletions SRPXX-Tests/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <string>
#include <vector>
#include <cstdint>
#include <memory>

class Constants
{
Expand All @@ -42,8 +43,8 @@ class Constants

friend void swap( Constants & o1, Constants & o2 );

SRP::Client makeClient() const;
SRP::Server makeServer() const;
std::unique_ptr< SRP::Client > makeClient() const;
std::unique_ptr< SRP::Server > makeServer() const;

SRP::HashAlgorithm hashAlgorithm() const;
SRP::Base::GroupType groupType() const;
Expand Down
Loading

0 comments on commit 6c8c0c6

Please sign in to comment.