#Understanding instructions
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
You teacher is lifting the veil on unit testing. 👍
so pretty much the code given i dont need to use it?
or do i need to use it to implement it inside of my code
Is the code you posted yours?
Or the teacher's?
teachers
i had like premade code that the teacher made me download
and like add into vs
TRUE or FALSE?
You will have written _array_init() and _print_array().
Okay, so you have those functions, but they are stubbed.
The teacher has given you some code. This code will test function _array_init(). And optionally it will also invoke _print_array().
You can just C&P that code into your file. I would suggest underneath functions _array_init() and _print_array().
In your main() you could call this test_init_array().
This is basically what a unit test would do under the hood.
Ah hang on.
#include "array_functions.h"
I didn't spot this until just now.
Are you working in a multi-file project?
If so, paste your teacher's code in the file that contains main().
It's probably called "main.cpp", but doesn't have to be.
I see a file called "main.cpp".
i added it in to this
is there a site where theres a explantion for the Includes
cuz some of the includes that were added in here i have never seen before
No, don't paste it inside of main().
Paste it above.
Then in main() add a call to this function.
Near the top of main.cpp you need to also add
#include "array_functions.h"
wdym by posting it above like above int main(int argv, char **argv)
It looks like you used <> instead?
Paste it just as I wrote it.
Yes, copy the function above the function main().
bool test_init_array(bool debug=false)
{
// the code
}
int main(int argv, char **argv)
{
cout << "\n" << endl;
// call function test_init_array() here
cout << "\n\n=======================" << endl;
}
Something like this
ohhh ok
and for the call functions
thats the thing where its like
private and public
No, that's for classes.
I cannot see any classes in your code.
Maybe it should be
#include "includes/array_functions.h"
It's difficult to make out the directory structure from a project-view window - especially if it's not an IDE that I am familiar with.
That's my excuse anyway.
LOL yea im like completely new to this
and like all this stuff i was introduced to never learned in my previous class
In fact, it might even be
#include "includes/array_functions/array_functions.h"
We could fix this in your CMakeLists.txt, but I fear that would take even longer and may just confuse.
"" is for local files in your project.
<> is for system and library headers.
ohhh ok
thanks for the help
if i have any more questions would i make a new post or just stick with this post
Up to you.
Might be easier for you to stick with this one.
Then you have all the information neatly in one thread.
ok thanks for the help again
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.
i had to include a array function in my code
i was given
#include "../../includes/stub/stub.h"
or add a array
but when i do
#include "includes/array_functions/stub/stub.h"
it doesnt work
i also tried to add it in front of the includes
and that didnt work as well
This is a matter of finding out where file stub.h lives relative to the source file from where you want to include it and the correct amount of ../ repeats.
Tedious and it's not something that any of us can give a definitive answer to.
I have techniques, but it requires the use of the command line.
Okay, the header file "stub.h" doesn't appear to be "above" your project in the folder structure.
Try #include "includes/stub/stub.h"
Does the file actually exist?
Again, not a champion on VStudio project views, but my suggestion appears to be correct based on your screenshot from before.
If you are proficient in command line use, perhaps cd to the project root directory and run
dir /s stub.h
i have never used command lines before
show your CMakeLists.txt
that’s where you would configure include dirs
or at least for your actual build anyway
for just the syntax check your do that by installing and configuring the C++ extension for VSCode
i had to send as a file
i also got this installed as well
use https://wandbox.org if you’re hitting discord message length limits
I’m on mobile rn, not going to download a file
or use pastebin.com or gist.github.com or any of many similar sites
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(cs3a)
#. . . . . . . . . . . . . . . . . .
like this?
this how u do it right
the thing is with this code my teacher was the one that provided that code
yes I see that
I’m not sure
in a case like this you really should have proper directions to follow given by your teacher
if not then go to office hours
or ask your TAs in the next lab
alright thanks for the help tho