Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions include/gauxc/shell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <array>
#include <cmath>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <cassert>
#include <algorithm>
#include <tuple>
Expand Down Expand Up @@ -138,6 +140,12 @@ class alignas(256) Shell {
alpha_( alpha ), coeff_( coeff ), O_( O ),
nprim_( nprim.get() ), l_( l.get() ), pure_( pure.get() ) {

if(nprim_ > static_cast<int32_t>(detail::shell_nprim_max)) {
std::ostringstream oss;
oss << "Shell has too many primitives! expected <= " << detail::shell_nprim_max << " actual value " << nprim_ << "!\n";
throw std::out_of_range(oss.str());
}

if( _normalize ) normalize();
compute_shell_cutoff();

Expand Down
21 changes: 21 additions & 0 deletions tests/basisset_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <random>
#include <algorithm>
#include <stdexcept>
#include <string>

#include <gauxc/gauxc_config.hpp>

Expand Down Expand Up @@ -184,6 +186,25 @@ TEST_CASE("Shell", "[basisset]") {

}

SECTION("Too Many Primitives") {

const auto nprim = PrimSize(detail::shell_nprim_max + 1);
const prim_array alpha = {0.8};
const prim_array coeff = {0.5};

try {
Shell<double> sh( nprim, AngularMomentum(0), SphericalType(false),
alpha, coeff, center );
FAIL( "Expected Shell construction to throw" );
} catch( const std::out_of_range& ex ) {
const std::string message = ex.what();
CHECK( message.find( "Shell has too many primitives!" ) != std::string::npos );
CHECK( message.find( "expected <= 32" ) != std::string::npos );
CHECK( message.find( "actual value 33" ) != std::string::npos );
}

}

}


Expand Down
Loading