Tag:Test code

  • Golang quick start unit testing (idea, framework, practice)

    Time:2021-10-12

    1. What is unit testing Unit testing can check whether our code can proceed as expected and whether there are problems in code logic, so as to improve code quality.In short, unit testing is to test a function method. We should first test the correct value transfer and obtain the correct expected results, and then […]

  • Question: how to parse JSON data? What are the methods?

    Time:2021-10-3

    This problem is what we as programmers have to do almost every day. How many ways does it have? Let’s talk about it here. Four ways of parsing Official analysis Google gson analytics Alibaba fastjason analysis Jackson analysis Case practice Here we will only discuss how objects and JSON convert to each other. Here, let’s […]

  • Learn the interesting character set internationalization verification function in PHP

    Time:2021-9-19

    Today’s content is very simple, but also very interesting. I don’t know if you have experienced such a thing, that is, in some fonts, 0 and o are difficult to distinguish, and 1 and L are also difficult to see clearly. Of course, the default fonts of most editors and ides now choose those that […]

  • Angular mock uses $httpbackend service to test $http

    Time:2021-9-19

    Introduction to angular mock The angular mock module provides module definition, loading, injection and other support for angular unit testing. Assist karma, jasmine and other JS testing tools to simulate the angular method and test the angular application. In addition, angular mock also extends NG’s multiple core services so that the tested code can be […]

  • yyjson vs luajit buffer vs lua-cjson

    Time:2021-9-9

    Luajit has introduced a new buffer interface, and yyjson is almost the fastest JSON C library (without SIMD instructions)Compare the performance of yyjson and luajit buffer.Test JSON file: performance testing using rapid JSONWarehouseTest files in: three files in the data directory: “. / Canada. JSON”, “. / twitter. JSON”, “. / citm_catalog. JSON” test machine: […]

  • Application of mathematical correlation function in PHP

    Time:2021-9-8

    For mathematical calculation, the most common operation is that we use various operators, such as + add, – subtract and so on. Of course, PHP also provides us with some operation functions that can easily perform other mathematical operations. These functions are math extensions. This extension is included in the PHP source code by default. […]

  • Two stage termination mode

    Time:2021-9-4

    Series articles: Two stage termination mode Protective pause mode Production consumer model Two stage termination mode Two-Phase Termination Patter Description: enables the monitoring thread to gracefully terminate other running worker threads Code implementation: class TwoPhaseTermination { Test code: public class TwoPhaseTerminationTest { public static void main(String[] args) { TwoPhaseTermination pattern = new TwoPhaseTermination(); pattern.start(); try […]

  • Protective pause mode

    Time:2021-9-3

    Series articles: Two stage termination mode Protective pause mode Production consumer model Protective pause mode Guarded Suspension Pattern Inter thread communication model, implementation principle of future and promise Code implementation: class GuardedSuspension { private Object response; public Object get () { synchronized (this) { while (response == null) { try { this.wait(); } catch (InterruptedException […]

  • Production consumer model

    Time:2021-9-1

    Series articles: Two stage termination mode Protective pause mode Production consumer model Production consumer model Blocking queues are used to control the generation and consumption of messages Code implementation: class MessageQueue { Test code: public class ProduceConsume { Operation effect: Java Design Patterns This work adoptsCC agreement, reprint must indicate the author and the link […]

  • C # implements a dictionary based on value equality comparison

    Time:2021-8-18

    C # implements a dictionary based on value equality comparison Intro Today, I met a requirement in the project. It’s probably like this. I want to compare whether two JSON strings are equal. The JSON string is actually oneDictionaryBut the order may be different, as in the previous articleRecord usage scenarioThe first requirement in is […]

  • 008 learn the implementation peek function of rust through linked list

    Time:2021-8-14

    introduce Video address:www.bilibili.com/video/av78062009/Relevant source code:github.com/anonymousGiga/Rust-link… Details In the previous linked list implementation, we did not implement the peek method to obtain the header element. This section attempts to implement it. peek According to our previous knowledge, we can quickly write the code as follows: pub fn peek(&self) -> Option<&T> { self.head.map(|node| { &node.elem }) } […]

  • 013 learn rust through the linked list to realize the general function of the linked list

    Time:2021-8-9

    introduce Video address:www.bilibili.com/video/av78062009/Relevant source code:github.com/anonymousGiga/Rust-link… Details In this section, we will implement the general function of the linked list based on the linked list defined in the previous section.Because the linked list in this chapter operates more on the head and tail of the linked list, we do not provide push and pop in general […]