Add unittest to IXSentryClient to lua backtrace parsing code

This commit is contained in:
Benjamin Sergeant
2019-10-26 10:54:47 -07:00
parent bbfa76a2c9
commit 081dd2c4bb
5 changed files with 25 additions and 11 deletions

View File

@ -2,28 +2,38 @@
* IXSentryClientTest.cpp
* Author: Benjamin Sergeant
* Copyright (c) 2019 Machine Zone. All rights reserved.
*
* (cd .. ; make) && ../build/test/ixwebsocket_unittest sentry
*/
#include "IXTest.h"
#include "catch.hpp"
#include <iostream>
#include <string.h>
#include <ixsentry/IXSentryClient.h>
using namespace ix;
namespace ix
{
TEST_CASE("sentry", "[sentry]")
{
SECTION("Attempt to perform nil")
SECTION("Attempt to index nil")
{
#if 0
SentryClient sentryClient;
std::string stack = "";
SentryClient sentryClient("");
std::string stack = "Attempt to index nil[overlay]!\nstack traceback:\n\tfoo.lua:2661: in function 'getFoo'\n\tfoo.lua:1666: in function 'onUpdate'\n\tfoo.lua:1751: in function <foo.lua:1728>";
auto frames = sentryClient.parseLuaStackTrace(stack);
REQUIRE(frames.size() > 0);
#endif
REQUIRE(frames.size() == 3);
}
SECTION("Attempt to perform nil")
{
SentryClient sentryClient("");
std::string stack = "Attempt to perform nil - 1572111278.299\nstack traceback:\n\tfoo.lua:57: in function <foo.lua:53>";
auto frames = sentryClient.parseLuaStackTrace(stack);
REQUIRE(frames.size() == 1);
}
}