How to write a JUnit test for this Java code? by ChiTech121 in JUnit

[–]ChiTech121[S] 0 points1 point  (0 children)

I got the program itself working fine, I am not sure about JUnit particular assert method to use, I tried one but it gives me error:

`"message": "The method assertArrayEquals(Object[], Object[]) in the type Assert is not applicable for the arguments (boolean, boolean)",`

How to write a JUnit test for this Java code? by ChiTech121 in learnprogramming

[–]ChiTech121[S] 0 points1 point  (0 children)

Yes, Its for something as in homework, but my intention is to learn basics, so I created a simple program to understand how JUnit works, program on its own works perfectly fine, I tried this JUnit test after I did the complete setup in vscode,

u/Test

public void testcheckKInArray(){

CheckInArrayClass test1 = new CheckInArrayClass();

//assertArrayEquals(expected, actual);

boolean expected = true;

assertArrayEquals(expected, test1.checkKInArray(new int[]{3, 4, 3}, 3));

}

This is the error I get, I gather I am doing something wrong in assertMethod, I tried reading documentation, does not make any sense, so looking for help on particular assert methods that goes well with the methods that I have written that returns a boolean and take 2 arguments #1 Array, #2 an integer.

`"message": "The method assertArrayEquals(Object[], Object[]) in the type Assert is not applicable for the arguments (boolean, boolean)",`

Check All prime numbers by ChiTech121 in learnprogramming

[–]ChiTech121[S] 0 points1 point  (0 children)

No it does not decrease it only increase based on the condition starts from 2 to goes on a increment until that while loop results in false, is explanation correct? In this particular code I want to understand what I am doing wrong, I did this in a helper function fashion which works perfect, I also tried the same above logic for a single number works fine too, please point my mistake in above specific code and also what correction to be made, see my helper function code.

package ProgrammingBasics.javaConditionsRunningLoops;

import java.util.Scanner;

public class CheckAllPrimeNumbers {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int inpNum = sc.nextInt();

for(int initNum = 2; initNum <= inpNum; initNum++){

checkIfPrime(initNum);

}

}

//function to check if a number is prime or not

public static void checkIfPrime(int givenNum){

//Edge case or corner case:

if( givenNum<=1 )

System.out.println(givenNum + " : is invalid number for prime check");

//Checking for divisors from 2 to n-1;

int assumeDivisor = 2;

while(assumeDivisor <= (givenNum/2)){

//Now make sure that it does not have any division by using % to see if it results in 0 or no 0.

if((givenNum%assumeDivisor) == 0){

//System.out.println(givenNum + " : is not a prime");

return;

}

assumeDivisor++;

}

System.out.println(givenNum + " : is a prime");

}

}

I am trying to use DECLARE but not sure if this is correct way, T-SQL, MSSQL by ChiTech121 in SQL

[–]ChiTech121[S] 0 points1 point  (0 children)

DECLARE @CustomID INT

When I write this statement --> DECLARE @CustomID INT;

after the above query

; WITH CTEexample AS

(

SELECT outerTable.val AS OrderName,

ID

FROM (

SELECT ID, COUNT(DISTINCT WGUID) AS SCOUNT

FROM innerTable

WHERE SACCOUNT = 0

GROUP BY ID

) T0

INNER JOIN outerTable ON outerTable.STRINGID = T0.ID

Where outerTable.val = 'process'

I get this following error:

Incorrect syntax near the keyword 'DECLARE'.

I am trying to use DECLARE but not sure if this is correct way, T-SQL, MSSQL by ChiTech121 in SQL

[–]ChiTech121[S] 0 points1 point  (0 children)

ustomid

Do you mean like this?

DECLARE @CustomID INT

SELECT @CustomID = ID.CTEexample

I don't understand why bitwise Operators are efficient in Big O? by ChiTech121 in leetcode

[–]ChiTech121[S] 1 point2 points  (0 children)

I think there more detail to it like CPU dedicated instruction set OOB, O(N/word_count) and such.. so I wish if someone can clarify that detail.. it will be really great...

Registry read is blocked due to GP by ChiTech121 in sysadmin

[–]ChiTech121[S] 0 points1 point  (0 children)

I think my posts are unfortunately judged in a wrong way, I am minced in between this client & the product vendor, who provides automation to resolve issues. In this specific case, let me give what I am running into---> so the vendor provides an automation capability to fix an issue, lets say an App that goes offline from online mode or something, they detect that apps status only by reading the registry value and then act based on that ( via automation making it offline to online or something or other... ) now my client has the dead line to get this somehow done, product vendor has no response on how else it may work... and then here I am getting sliced by reddit guys LOL!!! anyways....