/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: gettyimages-831129990-1503432258.jpg (480x720, 36K)

Other urls found in this thread:

youtu.be/sQurwqK0JNE
stackoverflow.com/questions/39239845/terminal-mock-for-unit-testing-python-curses-programs
twitter.com/SFWRedditVideos

How do I write unit tests for interactive shit like TUI (curses)?

It is impossible, isn't it?

Attached: 14586834926351.jpg (700x822, 78K)

I sincerely hope you didn't just throw it all into one unit, and instead made sure to cleanly seperate it into functionality that you can test, and an interface.

>posted in wrong thread
I was bamboozled
>What are you working on, Jow Forums?
I'm 27 and just got let go from my comfy logistics manager job, I got severance so I'll have a period of time that I can devote to learning a language and hopefully can keep learning while I work at another job.

I'll be learning C# so right now I'm watching
youtu.be/sQurwqK0JNE
Beginners From Bob Tabor (embed)
and hoping it will all click in to place since I'm a bit slow headed.

Attached: 1440217271549.jpg (858x536, 94K)

I can test logic and functionality separately but I want to test interface too since it always has issues like some data overflowing its supposed boundaries or issues with terminal resize and the following repositioning/resizing of elements.

This is the most relevant result I've found: stackoverflow.com/questions/39239845/terminal-mock-for-unit-testing-python-curses-programs

I might also just dump the whole curses screen into a string and compare it with expected string. Each time for each test with different datasets while simulating user's keypresses. But it feels retarded. Curses is a popular library, isn't there a better way?

Provide paid (((early access))) and let the users do the testing.

I have this template. It works but the issue is that it may take just about any function. Right now the lambda should be like [](AAimHud* h){...}. If I pass any other lambda the compiler will not complain but it should. Is there any way to check the signature at the beginning of the template? I'm not even sure if I'm explaining myself

// Lambda must take AAimHud* as parameter
template
void send_hud_message(F &message_lambda) {
const auto pc{ GetWorld()->GetFirstPlayerController() };
if (pc == nullptr) return;

const auto aim_hud{ Cast(pc->GetHUD()) };
if (aim_hud != nullptr) {
message_lambda(aim_hud);
}
}

So instead of using a parameter I just made a normal function with signature void send_msg(std::function message)

size_t pathSize = 4096;
char *path;
printf("[%s]$ ", getcwd(path, pathSize));


I can't figure out why it prints (null) but when I put & in front of path argument it prints out the right thing despite compilator giving me a warning.

You could use SFINAE.
template
void send_hud_message(F &&message_lambda)
{
/* ... */
}

Whoops, that should be std::enable_if_t. I don't use the raw std facilities for sfinae because of how ugly it is, I tend to use my own typedefs.

Has anyone here ever had the misfortune of having to use a .NET assembly in Delphi? I can import classes, methods etc from it using a tool that I found online and call them, but I run into issues when a method from the assembly expects a nullable arg.

Example: A class in the assembly has two fields; one required and one optional. The required one is simply an int, the optional one is Nullable. Each of those has a setter method.

DISCLAIMER: I am not experienced in C# so the syntax may be a little off. It should be enough to get my point across.

public class NetClass {
public int RequiredField { get; set; };
public Nullable OptionalField { get; set; };
}

When I try calling the setter for the int field in Delphi, everything is fine. Declare a variable of type Integer, pass it to the imported Delphi method which passes it along to the C# method.
However, I can't get the nullable types to work. I've tried using the Nullable type from the Spring framework as well as the built-in Nullable type (from System.Classes iirc) on the Delphi side, to no avail.

Lisp is the most powerful programming language.

i need help with asm
if i reserve some memory for runtime use like this:
SECTION .bss
Buffer: resb 1024
how can i make it expand and/or shrink during compile time (ex: program that reads files detects that 1024 is not enough so i double the size)

or should i use heap for this?

what a gay /dpt/ image, what the fuck man?

I've never done this myself, but perhaps you can mock using a Linux psuedo-terminal. Programs like emacs/tmux use ptys to run programs under and simulate terminal output within a subregion of a real terminal.

Screen resize testing would involve sending a SIGWINCH signal to child process. Your test harness wouldn't necessarily need to display anything... But WOULD need to keep track of virtual screen for comparison's sake.

It may be possible to script tmux to adjust pane size and use `tmux capture-pane -p -t $TARGET_PANE # pane-id snould be number with "%" in front`. Executing tmux from within tmux windows, with proper arguments allows manipulating panes/windows etc. A pane-capture strips out ANSI colors but would be string comparable, if direct pty programming too much to do.

He's a gud programmer

In order to have control over terminal output on windows you have 3 choices.
>ansi.sys (doesn't work on x64)
>windows.h (win api)
>ncurses
am I missing something

why does *(array +i) and &array[i] print out two different addresses for me?

&ptr[i] is equivalent to (ptr+i) not *(ptr+i)

int array[2]= 3;
printf("(array +2) = %d", (array+2));

(array+2) = 174897432
[\code]
I get it, but where is the computer getting this value from?

array == array[0]
doing array[0] + 1 you are increasing the value for 1 at position 0;

array[i] is completely different location.

or at least thats how i understand it

Pointers are a lot like integers. That's what a pointer looks like when you treat it as an integer.