|
-
September 8th, 2019, 05:30 AM
#1
[vsCode and gdb]: Breakpoints don't work with macros?
Hello!
I made a unit testing framework and for the first time, I noticed that breakpoints won't work with macros. This is how my tests look like:
main.cpp
Code:
#include <VampTest/VampTest.h>
#include <VampStructures/VampStructures.h>
bool compare(int current, int searching)
{
return current == searching;
}
VMPT_INIT
(
VMPT_TEST
(
linked_list, creation,
{
//Create the list.
VMPS::LinkedList<int> list;
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//The size of the list must be 10 by now.
VMPT_NOTEQUAL(10, list.getSize())
//Counter.
int i;
//Check the values.
for (i = 0; i < list.getSize(); i++)
if (list.hasNext())
VMPT_NOTEQUAL(i, list.getNext())
//I must be 10 by now.
VMPT_NOTEQUAL(10, i);
//list.hasNext() must return false at this point.
VMPT_NOTEQUAL(false, list.hasNext());
}
)
VMPT_TEST
(
linked_list, has_next_overflow,
{
//Create the list.
VMPS::LinkedList<int> list;
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//Check more that the size of the list.
//If .hasNext() works correctly, the text should succeed.
for (int i = 0; i < list.getSize()+20; i++)
if (list.hasNext())
VMPT_NOTEQUAL(i, list.getNext())
}
)
VMPT_TEST
(
linked_list, has_next_reset,
{
//Create the list.
VMPS::LinkedList<int> list;
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//Check more that the size of the list.
for (int i = 0; i < list.getSize(); i++)
if (list.hasNext())
VMPT_NOTEQUAL(i, list.getNext())
//Reset the list.
list.reset();
//has next must be true here.
VMPT_NOTEQUAL(true, list.hasNext());
//Counter.
int i;
//Check more that the size of the list.
for (i = 0; i < list.getSize(); i++)
if (list.hasNext())
VMPT_NOTEQUAL(i, list.getNext())
//I must be 10 by now.
VMPT_NOTEQUAL(10, i);
//list.hasNext() must return false at this point.
VMPT_NOTEQUAL(false, list.hasNext());
}
)
VMPT_TEST
(
linked_list, empty,
{
//Create the list.
VMPS::LinkedList<int> list;
//List must not have next when its empty.
VMPT_EQUAL(true, list.hasNext())
//Size must be zero.
VMPT_NOTEQUAL(0, list.getSize())
}
)
VMPT_TEST
(
linked_list, search,
{
//Create the list.
VMPS::LinkedList<int> list;
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//Search for number 5
void *n = list.search(compare, 5);
//5 MUST exist in the list.
VMPT_EQUAL(true, (n == list.end()) )
//list.get() should return 5.
VMPT_NOTEQUAL(5, list.get(n))
//Search for number 11
n = list.search(compare, 11);
//11 MUST not exist in the list.
VMPT_NOTEQUAL(true, (n == list.end()) )
}
)
VMPT_TEST
(
linked_list, clear,
{
//Create the list.
VMPS::LinkedList<int> list;
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//Clear the list.
list.clear();
//The list must be empty by now.
VMPT_NOTEQUAL(0, list.getSize())
//List must not have next when its empty.
VMPT_EQUAL(true, list.hasNext())
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//Counter.
int i = 0;
//Get the items.
while (list.hasNext())
{
VMPT_NOTEQUAL(i, list.getNext())
i++;
}
//Size must be ten by now.
VMPT_NOTEQUAL(10, list.getSize())
//I must be 10 by now.
VMPT_NOTEQUAL(10, i);
//list.hasNext() must return false at this point.
VMPT_NOTEQUAL(false, list.hasNext());
}
)
VMPT_TEST
(
linked_list, remove_item,
{
//Create the list.
VMPS::LinkedList<int> list;
//Fill it with 10 values.
for (int i = 0; i < 10; i++)
list.append(i);
//find number 5.
void *s = list.search(compare, 5);
//Remove the node which holds number 5.
int num = list.remove(s);
//Remove must return 5.
VMPT_NOTEQUAL(5, num);
//The size must be 9.
VMPT_NOTEQUAL(9, list.getSize());
//Remove all the remaining values.
int i = 0;
while (list.getSize() > 0)
{
s = list.search(compare, i);
if (i == 5)
VMPT_NOTEQUAL( true, (s==list.end()) )
else
{
num = list.remove(s);
VMPT_NOTEQUAL(i, num);
}
i++;
}
//The size must be 0.
VMPT_NOTEQUAL(0, list.getSize());
//Has next must be false.
VMPT_NOTEQUAL(false, list.hasNext());
}
)
)
The problem is that if I add a break point somewhere in main.cpp the breakpoint won't stop the debugger at that point. If I add a breakpoint inside the implementation of the code which I'm testing the break point works.
I am exporting debugging symbols in the compilation.
Is this an expected behavior and why? How can I debug this code then?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|