试用AI Assistant 的一天

241 阅读1分钟

全部功能如图:

image.png

 

Explain Code

  image.png  

Suggest Refactoring

image.png

Find Problems

  image.png

 

Write Documentation

image.png  

Generate Unit tests

生成单元测试有点问题

image.png  

Convert File to Another Language

  image.png

// Import necessary libraries  
#include <iostream>  
#include <string>  
#include <vector>  
#include <chrono>  
#include <ctime>  
#include <cstdlib>  
#include <cstdio>  
#include <boost/process.hpp>  
#include <windows.h>  
  
namespace bp = ::boost::process;  
  
class TestService {  
    std::string name;  
public:  
    TestService(std::string name) : name(name) {}  
    std::string get_name() {  
        return name;  
    }  
};  
  
std::string getUserName() {  
    return "Zhang San";  
}  
  
void test() {  
    try {  
        bp::ipstream pipe_stream;  
        bp::child child_process("cmd.exe", bp::std_out > pipe_stream);  
        std::string line;  
  
        std::cout<<"Process ID: "<< child_process.id()<<std::endl;  
  
        while (pipe_stream && std::getline(pipe_stream, line) && !line.empty())  
            std::cerr << line << std::endl;  
         
        // Additional information  
        DWORD aProcesses[1024], cbNeeded, cProcesses;  
        unsigned int i;  
  
        if (EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))  
    {  
        cProcesses = cbNeeded / sizeof(DWORD);  
        for ( i = 0; i < cProcesses; i++ )  
        {  
            if( aProcesses[i] != 0 )  
            {  
                HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,  
                                            FALSE, aProcesses[i]);  
                // GetProcessName(hProcess);  
                CloseHandle( hProcess );  
            }  
        }  
    }  
    }  
  
    catch (std::exception const& e) {  
        std::cerr << "Exception: " << e.what() << std::endl;  
        return EXIT_FAILURE;  
    }  
  
    child_process.wait();  
}