diff --git a/avogadro/core/mdlvalence_p.h b/avogadro/core/mdlvalence_p.h index b2731f44bd..b642c6f823 100644 --- a/avogadro/core/mdlvalence_p.h +++ b/avogadro/core/mdlvalence_p.h @@ -97,7 +97,7 @@ static unsigned int atomValence(const unsigned char atomicNumber, case -1: return 2; case 0: - if (numBonds <= 3) + if (numBonds != 5) return 3; return 5; case 1: diff --git a/tests/qtgui/hydrogentoolstest.cpp b/tests/qtgui/hydrogentoolstest.cpp index 776ca12af4..10fdd9c276 100644 --- a/tests/qtgui/hydrogentoolstest.cpp +++ b/tests/qtgui/hydrogentoolstest.cpp @@ -173,9 +173,10 @@ TEST(HydrogenToolsTest, valencyAdjustment_N) RWAtom N = mol.addAtom(7); int expectedAdjustment = 3; for (int i = 0; i < 8; ++i, --expectedAdjustment) { - if (i == 4) // neutral N can have 3 or 5 bonds in our valence model. - expectedAdjustment += 2; - EXPECT_EQ(expectedAdjustment, HydrogenTools::valencyAdjustment(N)); + if (i == 5) // neutral N can have 3 or 5 bonds in our valence model. + EXPECT_EQ(0, HydrogenTools::valencyAdjustment(N)); + else + EXPECT_EQ(expectedAdjustment, HydrogenTools::valencyAdjustment(N)); mol.addBond(mol.addAtom(1), N, 1); } }