These problems are reported by my static analyzer on smart pointers.
In GTest, the ASSERT_* macro will stop the execution of the current test case or function, while EXPECT_* will not. Besides, If the ASSERT_* macro is used in a sub-function of a test case, it will only stop the execution of the current function and return to the caller test function. Although a test failure will be reported, the test program will still crash, which will skip some unit tests in the current test program. (See https://github.com/google/googletest/blob/master/googletest/docs/primer.md#basic-assertions)
In addition, in some test cases, the return value of a parser function is checked in a wrapper function, but both branches are allowed to reach the dereference site.
In this patch, I fixed some of the nullptr dereference with the problems above. The fix will not dismiss any check failures but can make the test program skip the current test case and continue with the next, rather than crash immediately.
clang-format: please reformat the code